Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2537 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
4
jan. 17
4622
2
aug. 25
3997
1
jun. 24
3371
1
jul. 23
2148
1
jun. 23
1775