跳至内容
菜单
此问题已终结
1 回复
2550 查看

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?

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
4
1月 17
4631
2
8月 25
4020
1
6月 24
3395
1
7月 23
2160
1
6月 23
1775