I want the client to be force to choose the journal in the invoice form view and not to have the first pre-selected.
Which is the correct way to remplace default, on the partner_id field change the the default journal choose event is tigger.
Edit
If I try to override the onchange_partner_id function I get the following error:
File "/opt/PycharmProjects/gca_odoo/clientes/client_PRINCE/models.py", line 22, in onchange_partner_id
self.journal_id = False
File "/opt/PycharmProjects/gca_odoo/3party/server/openerp/fields.py", line 847, in __set__
record.ensure_one()
File "/opt/PycharmProjects/gca_odoo/3party/server/openerp/models.py", line 5306, in ensure_one
raise except_orm("ValueError", "Expected singleton: %s" % self)
except_orm: ('ValueError', 'Expected singleton: account.invoice()')
I use the following code:
class account_invoice(models.Model):
_inherit = 'account.invoice'
@api.multi
def onchange_partner_id(self, type, partner_id, date_invoice=False,payment_term=False, partner_bank_id=False, company_id=False):
ret = super(account_invoice,self).onchange_partner_id(type=type, partner_id= partner_id,
date_invoice=date_invoice,payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id)
self.journal_id = False
return ret
You can override the onchange method, call is as super and after that, set the jopurnal field to False, in order to empty it.
EDIT: You are using the multi decorator. You should use one instead.