Ir al contenido
Odoo Menú
  • Inicia sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Inteligencia artificial
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de propiedades
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Comunidad
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

copy purchase order line

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
purchaselinecopyduplicate
1 Responder
5136 Vistas
Avatar
Thibaud

Hello,


Any ideas on how to copy a purchase order line ?

I'm trying firstly to create an object vals and using create method but always got following errors like :

[object with reference: Purchase Order - purchase.order]

I tried :

self.copy(default={'product_id': self.product_id})

but no effect too.


What I'm trying to do is when I pass a value in the colum free unit of a purchase order line, this line should duplicate and takes custom values that I set programmatically.

I use an onchange method on free_unit for this.

0
Avatar
Descartar
Avatar
Thibaud
Autor Mejor respuesta

Hey so I've tried the following code :

# Free unit
@api.onchange('free_unit')
def onchange_free_unit(self):
if self.free_unit > 0:
# looking for the id
search_ids = self.env['purchase.order'].search([])
last_id = search_ids and max(search_ids)
print last_id.id + 1
print self._origin.order_id.id

# check if the order line is saved
if last_id.id == self._origin.order_id.id:
print 'same !!!! \n'
new_line = {
'order_id': self._origin.order_id.id,
'product_id': self.product_id.id,
'name': self.name,
'product_qty': self.product_qty,
'date_planned': self.date_planned,
'date_ok': self.date_ok,
'product_uom': 1,
'price_unit': self.price_unit,
'taxes_id': self.taxes_id,
'cascade_bool': True,
}
print "new_line", new_line
self.create(new_line)
if not self._origin.order_id.id:
print 'not same !!! \n'
new_line = {
'order_id': last_id.id + 1,
'product_id': self.product_id.id,
'name': self.name,
'product_qty': self.product_qty,
'date_planned': self.date_planned,
'date_ok': self.date_ok,
'product_uom': 1,
'price_unit': self.price_unit,
'taxes_id': self.taxes_id,
'cascade_bool': True,
}
print "new_line", new_line
self.create(new_line)


So I'm trying to retreive the order_id to put it in the object. But it seems like it's impossible to do it in draft mode. I mean when the object is not saved.

I can do it when the object is saved and edit mode, but not in my purchase order before.


Any ideas ?? Or is it impossible ?

Thanks

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Why my custom copy button functionality is not working?
copy duplicate
Avatar
0
abr 15
5103
return wizard from def copy()
wizard copy duplicate odoo16features
Avatar
0
mar 24
2504
return wizard from def copy()
wizard copy duplicate odoo16features
Avatar
0
mar 24
2482
Duplicate html field v13 (Beginner)
fields copy duplicate quality
Avatar
0
abr 21
4135
Invoice (or other reports) 'Original' 'Duplicate' and 'Triplicate'
invoice print copy duplicate
Avatar
Avatar
1
mar 15
10840
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now