[FIX] account: unlink data when installing chart of account

When a chart of account is installed, it first remove all existing
existing data. If you don't have account_accountant module installed,
but you have create a bank or cash journal (through the POS for
example). Some accounts have been created and the installation of chart
template is trying to remove some models, but as the account_accountant
you don't have access write on model 'account.reconcile.model'.
This commit is contained in:
Pierre Masereel
2019-08-01 17:59:53 +00:00
parent f8ff7debdc
commit 56331c1a75
+1 -1
View File
@@ -214,7 +214,7 @@ class AccountChartTemplate(models.Model):
# delete account, journal, tax, fiscal position and reconciliation model
models_to_delete = ['account.reconcile.model', 'account.fiscal.position', 'account.tax', 'account.move', 'account.journal']
for model in models_to_delete:
res = self.env[model].search([('company_id', '=', company.id)])
res = self.env[model].sudo().search([('company_id', '=', company.id)])
if len(res):
res.unlink()
existing_accounts.unlink()