Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
1897 Tampilan

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
Avatar
Buang

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

Penulis Jawaban Terbai
@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!


Avatar
Buang

Hello Okatent;

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