Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
1916 Vizualizări

I want that when you change the suplier in the Purchas Order, automatically change the description of the products in the order lines, meeting the code and the name of that supplier if it is specified in  the product. The problem is that this code changes everything to the first value. What can I do to go line by line checking the product name and not putting all time the same

@api.onchange('partner_id')
def _onchange_partner_id(self):
for order in self:
product_lang = self.product_id.with_context(
lang=self.partner_id.lang,
partner_id=self.partner_id.id,
)
self.name = product_lang.display_name
if product_lang.description_purchase:
self.name += '\n' + product_lang.description_purchase
for line in order.order_line:
line.name = self.name
Imagine profil
Abandonează

Hi bro, 

I edited my answer to match your odoo version V12, its right here :

https://www.odoo.com/fr_FR/forum/aide-1/question/change-products-when-supplier-is-changed-160405#answer-160425

Autor Cel mai bun răspuns
@api.onchange('partner_id')
def _onchange_partner_id(self):
for line in self.order_line:
product_lang = line.product_id.with_context(
lang=self.partner_id.lang,
partner_id=self.partner_id.id, )
name = product_lang.display_name
if product_lang.description_purchase:
name += '\n' + product_lang.description_purchase
line.name = name

This is the solution, thank you all for your help!


Imagine profil
Abandonează

Hello Okatent;

may you please share where/how we should apply your solution. Thanks in advance.