Ir al contenido
Odoo Menú
  • Iniciar 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
    • Aprobaciones
    • 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 bienes inmuebles
    • 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
  • Odoo Community
    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

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
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

Odoo11 - onChange - Update copy/duplicate field to other model.

Suscribirse

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

Se marcó esta pregunta
many2manycopyduplicateonchange_eventodoo11
1 Responder
8843 Vistas
Avatar
Gabriel
Hello everyone,
 I have two models product_template  and sale_order_line.
In the product_template template I have some fields that are characteristic
of this product this field calls product characteristic

class productCharacteristcs (models.Model):
   _inherit = 'product.template'
   caractheristic_product = fields.Many2many (comodel_name = 'caracteristic.product.')
In my model sale_order_line there is this same field, but now it is 
related to another table, which may or may not be different for each sale. 
​
saleProductCharacteristcs (models.Model):
   _inherit = 'sale.order.line
   sale_caractheristic_product = fields.Many2many (comodel_name = 'sale.caracteristic.product.')

I would like the event onchange to automatically populate sale.order.line but 
based on the product information and change as i like

I found information like this: self.update ({ 'attendance_line': [(0, 0, {values})], }) But I tried here and unfortunately it was unsuccessful


0
Avatar
Descartar
Avatar
Waleed Ali Mohsen
Mejor respuesta

Hi, if I understand you correctly, you can try the below:

You already in sale.order.line model and you want to use onchange for sale_caractheristic_product field to populate sale line data

So you can use the below:

@api.onchange('sale_caractheristic_product ')
def _onchange_sale_caractheristic_product (self):
//Do you check here to retrieve the required data //Set values to sale line  
self.product_id = 
self.product_uom_qty =
..
etc
0
Avatar
Descartar
Gabriel
Autor

Hi, unffortily wont work.

What i want to do is, grab product caracteristics and use it on sale_product_caracteristc,.

If i change sale_product_caracterist i wont it change on product_caracteristcs.

Waleed Ali Mohsen

You will use something like that:

self.update({'move_line_ids': [(0, 0, {

'product_id': self.product1.id,

'product_uom_id': self.uom_unit.id,

'qty_done': 2,

'product_uom_qty': 0,

'lot_id': False,

'package_id': False,

'result_package_id': False,

'location_id': move1.location_id.id,

'location_dest_id': move1.location_dest_id.id,

})]})

Gabriel
Autor

Hi, that was perfect.. but i need one last help :/

I'm trying insert multiples lines, when i use a for, like

for x in move_line_ids:

It will just show the last line, the cursor pass over the first,secound, etc, but only show the last one.

Some Tip?

Waleed Ali Mohsen

Yes, it will show only the last one so you have to have a loop and append all line into list and then assigned it to your ids in update method as below:

You can do something like this:

update = []

for record in data.order_line:

update.append((0, 0, {

'product_id': record.product_id.id,

'product_uom': record.product_uom.id,

'order_id': record.order_id.id,

'name': record.name,

'product_qty': record.product_uom_qty,

'price_unit': record.price_unit,

'taxes_id': False,

'product_subtotal': record.price_subtotal,

'analytic_account_id': record.order_id.analytic_account_id.id,

}))

self.update({'new_order_line_ids': update})

Gabriel
Autor

Last 2 question i promisse...

If a field, integer, its not show in the many2many table widget, it wont be update corret? even if i got:

update.append((0, 0, {

'product_id': record.product_id.id, -- Show field in the table

'numeric_field': record.product_id.numeric_field.id, -- Not show field in the widget table

}))

If inside the order_line_id i got a field many2one i wont be able to update that to?

update.append((0, 0, {

'product_id': record.product_id.id,

'attributes': record.product_id.ids, -- this field is many2many

}))

Even if this case i use something like

'attributes': ((0,0{'id':1})),

I promisse i will compile every information and make a anser in the end :P

¿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
Add column to a many2many rel table Resuelto
many2many odoo11
Avatar
Avatar
1
nov 19
6079
Why my custom copy button functionality is not working?
copy duplicate
Avatar
0
abr 15
4304
how to format mapped() result Resuelto
many2many mapping odoo11
Avatar
Avatar
2
jun 20
12473
Problem with M2M Fields Resuelto
many2many problem odoo11
Avatar
Avatar
Avatar
2
nov 18
7046
Copying Many2many field values to another Many2many field
fields many2many copy
Avatar
0
may 16
6852
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 ภาษาไทย 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