[FIX] account: Set default for invoices

In 12.0, the function onchange_default defined in odoo/models.py
was triggered on model 'account.invoice' for the fields type, company_id,
partner_id

In 13.0, as the model 'account.invoice' has been removed by 'account.move',
the same logic must be applied on this model.

opw:2086812

closes odoo/odoo#38925

X-original-commit: 04deb9593342450cda381699b788c4a0205eec76
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
This commit is contained in:
Goffin Simon
2019-10-17 08:55:38 +00:00
committed by fw-bot
parent 19e4b89d65
commit 32caafd5bd
+3 -3
View File
@@ -106,7 +106,7 @@ class AccountMove(models.Model):
('out_receipt', 'Sales Receipt'),
('in_receipt', 'Purchase Receipt'),
], string='Type', required=True, store=True, index=True, readonly=True, tracking=True,
default="entry")
default="entry", change_default=True)
to_check = fields.Boolean(string='To Check', default=False,
help='If this checkbox is ticked, it means that the user was not sure of all the related informations at the time of the creation of the move and that the move needs to be checked again.')
journal_id = fields.Many2one('account.journal', string='Journal', required=True, readonly=True,
@@ -115,7 +115,7 @@ class AccountMove(models.Model):
default=_get_default_journal)
user_id = fields.Many2one(related='invoice_user_id', string='User')
company_id = fields.Many2one(string='Company', store=True, readonly=True,
related='journal_id.company_id')
related='journal_id.company_id', change_default=True)
company_currency_id = fields.Many2one(string='Company Currency', readonly=True,
related='journal_id.company_id.currency_id')
currency_id = fields.Many2one('res.currency', store=True, readonly=True, tracking=True, required=True,
@@ -127,7 +127,7 @@ class AccountMove(models.Model):
partner_id = fields.Many2one('res.partner', readonly=True, tracking=True,
states={'draft': [('readonly', False)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
string='Partner')
string='Partner', change_default=True)
commercial_partner_id = fields.Many2one('res.partner', string='Commercial Entity', store=True, readonly=True,
compute='_compute_commercial_partner_id')