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

Hi,

I would like to get the selected customer (partner_id) of sale.order from sale.order.line model, I haven't succeeded yet.

Here is my source code

@api.onchange('product_id')
def _compute_customer_code(self):
if self.product_id.id:
partner_id = self.browse(order_id).partner_id or 0

One more question, is there any way to check the onchange of partner_id of sale.order for updating the related value in sale.order.line?

Thank you for your help!

Imagine profil
Abandonează
Cel mai bun răspuns

Hi Thanhps,

Why are you doing a browse to try and get the ID though? Why don't you simply get it through the link from sale.order.line to sale.order? For example:


@api.onchange('product_id') def _compute_customer_code(self):
if self.product_id:
partner_id = self.order_id.partner_id

You can write an onchange on the field 'partner_id' to update values from there too. For example:

@api.onchange('partner_id')
def change_order_lines(self):
    for line in self.order_line:
        line. write(!'field': 'value'}) ​   ​

Regards,

Yenthe

Imagine profil
Abandonează
Autor

Thank you so much for your help! :)

Related Posts Răspunsuri Vizualizări Activitate
0
iun. 19
8090
2
dec. 24
21702
0
sept. 24
1281
3
aug. 24
2560
0
feb. 24
1716