[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>
This commit is contained in:
Olivier Colson
2019-06-26 08:11:17 +00:00
parent 793933a128
commit 8c7d7e0c2f
+8 -4
View File
@@ -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