summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Colson <oco@odoo.com>2019-06-25 12:02:26 +0000
committerOlivier Colson <oco@odoo.com>2019-06-26 08:11:17 +0000
commit8c7d7e0c2f4d95dff585f0fd06b6a2376febf062 (patch)
treea60e2669bbf0d85b23cfe217ec9cdafd826aafe8
parent793933a1287d08c174d7ba00ed4762d1807b4923 (diff)
[FIX] account: correct default country on new tax repartition lines
When creating a new tax, before saving, the default-computed repartition lines had no country_id associated. It only 'appeared' when saving the record. closes odoo/odoo#34359 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
-rw-r--r--addons/account/models/account.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 6e7b87d3423..eb86c2da02f 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -1071,16 +1071,20 @@ class AccountTax(models.Model):
rslt = super(AccountTax, self).default_get(vals + ['company_id'])
company_id = rslt.get('company_id')
+ company = self.env['res.company'].browse(company_id)
+
if 'refund_repartition_line_ids' in vals:
+ # We write on the related country_id field so that the field is recomputed. Without that, it will stay empty until we save the record.
rslt['refund_repartition_line_ids'] = [
- (0, 0, { 'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id}),
- (0, 0, { 'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id}),
+ (0, 0, { 'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
+ (0, 0, { 'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
]
if 'invoice_repartition_line_ids' in vals:
+ # We write on the related country_id field so that the field is recomputed. Without that, it will stay empty until we save the record.
rslt['invoice_repartition_line_ids'] = [
- (0, 0, { 'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id}),
- (0, 0, { 'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id}),
+ (0, 0, { 'repartition_type': 'base', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
+ (0, 0, { 'repartition_type': 'tax', 'factor_percent': 100.0, 'tag_ids': [], 'company_id': company_id, 'country_id': company.country_id.id}),
]
return rslt