Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2415 Vistas

Hi all!


I want to add sale.order.line in crm.lead form

To testing my code I use "debugging" -> `Edit View` button.


Now, when i added my code:on crm.lead form.

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 















There are no data from sale.order.line , only empty lines https://fex.net/ru/s/fmsv7o3 (image). But in the sale.order view i can see all data from sale.order.line https://fex.net/ru/s/fcvxydt (image)



What I can do, to have this data on crm.lead form?

Avatar
Descartar
Mejor respuesta

Hi Nikolay Kolesnyk,

I am not sure whether you have added code here because it is not visible.

    As it is One2many field, it cannot be assigned directly; you need to use special commands to create lines in crm.lead.

  Check the below steps:

    1. In crm.lead, define One2many field.

    Logic:

    2. Define an empty list (val_list) -> Loop through sale.order.line and prepare a dictionary of values (dict_value) for each line -> Append it to the list.
val_list = []
for line in sale_rec.order_line:
      val_list.append((0, 0, dict_value))       # (0, 0, {}) is special command that creates a record when executed

    3. Assign val_list to lines while creating and updating crm.lead record.
      {'lines': val_list, ...}

I hope it will be useful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
4
ene 17
4460
1
jun 24
3159
1
jul 23
2040
1
jun 23
1774
2
ene 23
3809