跳至内容
菜单
此问题已终结
1 回复
4720 查看

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

相关帖文 回复 查看 活动
0
12月 18
13
1
9月 23
6915
1
8月 22
8295
5
3月 22
19806
1
7月 19
7295