Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8635 มุมมอง

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!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

Thank you so much for your help! :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
มิ.ย. 19
8177
How to add a sequence a field? แก้ไขแล้ว
2
ธ.ค. 24
21764
0
ก.ย. 24
1321
3
ส.ค. 24
2635
0
ก.พ. 24
1745