[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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user