summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2019-09-19 08:12:32 +0000
committerwan <wan@odoo.com>2019-09-19 08:12:32 +0000
commit978f9ce2c6ccd7b69a1da454c43b1b735e0bc8cf (patch)
tree4ff7906e99827ab36323055a2130d711edda6bed
parent78c0934f76f30776f26d33d134abaa67c3491f1b (diff)
[FIX] account: onchange in reconcile model
The onchange on tax_ids and second_tax_ids was only recomputed when tax_ids changes (duh) so the variables show_force_tax_included and show_second_force_tax_included were not set when coming back to the formm after having saved a line with one tax. closes odoo/odoo#37111 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
-rw-r--r--addons/account/models/account_reconcile_model.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py
index 3a70d0516ae..56a8fc81a4e 100644
--- a/addons/account/models/account_reconcile_model.py
+++ b/addons/account/models/account_reconcile_model.py
@@ -97,7 +97,7 @@ class AccountReconcileModel(models.Model):
('percentage', 'Percentage of balance'),
('regex', 'From label'),
], required=True, default='percentage')
- show_force_tax_included = fields.Boolean(store=False, help='Technical field used to show the force tax included button')
+ show_force_tax_included = fields.Boolean(compute='_compute_show_force_tax_included', help='Technical field used to show the force tax included button')
force_tax_included = fields.Boolean(string='Tax Included in Price',
help='Force the tax to be managed as a price included tax.')
amount = fields.Float(string='Write-off Amount', digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.")
@@ -118,7 +118,7 @@ class AccountReconcileModel(models.Model):
('percentage', 'Percentage of balance'),
('regex', 'From label'),
], string="Second Amount type",required=True, default='percentage')
- show_second_force_tax_included = fields.Boolean(store=False, help='Technical field used to show the force tax included button')
+ show_second_force_tax_included = fields.Boolean(compute='_compute_show_second_force_tax_included', help='Technical field used to show the force tax included button')
force_second_tax_included = fields.Boolean(string='Second Tax Included in Price',
help='Force the second tax to be managed as a price included tax.')
second_amount = fields.Float(string='Second Write-off Amount', digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.")
@@ -159,18 +159,26 @@ class AccountReconcileModel(models.Model):
def _onchange_tax_ids(self):
# Multiple taxes with force_tax_included results in wrong computation, so we
# only allow to set the force_tax_included field if we have one tax selected
- self.show_force_tax_included = False if len(self.tax_ids) != 1 else True
if len(self.tax_ids) != 1:
self.force_tax_included = False
+ @api.depends('tax_ids')
+ def _compute_show_force_tax_included(self):
+ for record in self:
+ record.show_force_tax_included = False if len(record.tax_ids) != 1 else True
+
@api.onchange('second_tax_ids')
def _onchange_second_tax_ids(self):
# Multiple taxes with force_tax_included results in wrong computation, so we
# only allow to set the force_tax_included field if we have one tax selected
- self.show_second_force_tax_included = False if len(self.second_tax_ids) != 1 else True
if len(self.second_tax_ids) != 1:
self.force_second_tax_included = False
+ @api.depends('second_tax_ids')
+ def _compute_show_second_force_tax_included(self):
+ for record in self:
+ record.show_second_force_tax_included = False if len(record.second_tax_ids) != 1 else True
+
@api.onchange('match_total_amount_param')
def _onchange_match_total_amount_param(self):
if self.match_total_amount_param < 0 or self.match_total_amount_param > 100: