Skip to Content
Menú
This question has been flagged
1 Respondre
2552 Vistes

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
Best Answer

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
Related Posts Respostes Vistes Activitat
4
de gen. 17
4633
2
d’ag. 25
4022
1
de juny 24
3401
1
de jul. 23
2160
1
de juny 23
1775