Skip to Content
Menu
This question has been flagged
1 Reply
2343 Views

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
Discard
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
Discard
Related Posts Replies Views Activity
4
Jan 17
4407
1
Jun 24
3048
1
Jul 23
1977
1
Jun 23
1774
2
Jan 23
3712