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

Hello,

I dont know how to change many2one field in onchange method.

What i need to do is: when someone is creating a new invoice and changing currency, bank account changing in the same time. I'm using exception to have a look at the value of partner_bank_account.

@api.onchange('currency_id')
	def currency_id_change(self):
		if self.currency_id:
			return {
                            'value': {
                                'partner_bank_id': ????????????????,
                                    }
                                }
			raise except_orm(('Warning!'), (self.partner_bank_id))

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

Hi,

You may try like this,  if you use single partner bank account for one currency:

@api.onchange('currency_id')
def _currency_id_change(self):
     
     if self.currency_id:
         bank_account_rec = self.env['res.partner.bank'].search(['currency_id','=',self.currency_id.id])
         self.partner_bank_id = bank_account_rec.id
         

Hope this helps!

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

It works without changing anything. Thanks a lot Akhil p Sivan

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ธ.ค. 18
13
1
ก.ย. 23
6989
1
ส.ค. 22
8456
5
มี.ค. 22
19885
1
ก.ค. 19
7414