[FIX] account: change CoA even if one already installed

Because the tax closing entry is created (empty) at the creation of the
CoA, it is not possible anymore to change it later, even if the user
didn't create any journal entry.
By checking that there are no account.move.line instead of account.move,
and also there are no entries with a name different from '/' (to ensure
that the sequences are untouched) we can change the CoA if needed.

closes odoo/odoo#44659

X-original-commit: 8928dfe70867da3e40fa47f50bffa5dfd1976090
Signed-off-by: wan <william-andre@users.noreply.github.com>
This commit is contained in:
wan
2020-02-05 14:10:11 +00:00
parent 76e31253e6
commit b2feb8b7f4
+3 -1
View File
@@ -272,10 +272,12 @@ class AccountChartTemplate(models.Model):
the provided company (meaning hence that its chart of accounts cannot
be changed anymore).
"""
model_to_check = ['account.move', 'account.payment', 'account.bank.statement']
model_to_check = ['account.move.line', 'account.payment', 'account.bank.statement']
for model in model_to_check:
if self.env[model].sudo().search([('company_id', '=', company_id.id)], limit=1):
return True
if self.env['account.move'].sudo().search([('company_id', '=', company_id.id), ('name', '!=', '/')], limit=1):
return True
return False
def _create_tax_templates_from_rates(self, company_id, sale_tax_rate, purchase_tax_rate):