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

Hello everyone

i want custom form invoice customer in accounting odoo. I use domain in python. But it can't working.

@api.onchange('partner_id')    

def _get_partner_info(self): 

res = {}  

if self.partner_id: 

res['domain'] = {'partner_bank_id':[('partner_id','=',self.partner_id.id)]}          

else:            

pass             

return res ​


 Please help me. Thank all

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

Hi Hoang,

Your code looks fine to me. Please check if the partner_bank_id field has widget="selection" or not. If yes, please remove it and then try again.

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

You can follow this: https://youtu.be/XGqXEL2qQmE

Hope it helps,

Thanks

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

It in xml and python has not widget. I don't know why code not working :(

<field name="partner_bank_id" attrs="{'invisible': [('payment_type', '=', '2')], 'readonly': [('state', '!=', 'draft')]}"/>

---UPDATE

I found issue in F12. piece of code in  origin code override my code. Origin code have result

  1. result: {domain: {partner_bank_id: [["partner_id.ref_company_ids", "in", [1]]]}, value: {}}
    1. domain: {partner_bank_id: [["partner_id.ref_company_ids", "in", [1]]]}
      1. partner_bank_id: [["partner_id.ref_company_ids", "in", [1]]]
        1. 0: ["partner_id.ref_company_ids", "in", [1]]

So how i can override origin code ? Thanks

อวตาร
ละทิ้ง

Hi Quân.

may be exists 2 function onchange for pảtner_id field. pls recheck again.