Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Onchange many2one partner_bank_id

By
John Doe
on 5/9/16, 4:42 AM 290 views

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))

2

Akhil P Sivan

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 5/9/16, 6:49 AM

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

John Doe
on 5/10/16, 8:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/9/16, 4:42 AM
Seen: 290 times
Last updated: 5/9/16, 7:26 AM