[FIX] account: change accounting plan access

opw-1916511

When you try to change the accounting plan it sets off an access error.
To change the accounting plan it must delete and create some records in
the model 'ir.property' and none of the current security groups have
access to do it.

This issue was not present in the version 11.0 because in that version
the administrator was also the super-user.
In version 12.0 the administrator and the super-user were dissociated.

This was changed to level-up (sudo) the rights of the administrator
when the ir.property are deleted.

Note that, this fonction have two pre-existing constraints to avoid
issues when configuring an accounting plan: it can only be changed if
there are not alredy existings accounting entries;
and only the administrator can change it.

closes odoo/odoo#29493
This commit is contained in:
Jorge Pinna Puissant
2018-12-14 09:23:10 +00:00
parent 5f4a945182
commit 9d0d5b6e8c
+1 -1
View File
@@ -211,7 +211,7 @@ class AccountChartTemplate(models.Model):
prop_values.extend(['account.journal,%s' % (journal_id,) for journal_id in existing_journals.ids])
accounting_props = self.env['ir.property'].search([('value_reference', 'in', prop_values)])
if accounting_props:
accounting_props.unlink()
accounting_props.sudo().unlink()
# delete account, journal, tax, fiscal position and reconciliation model
models_to_delete = ['account.reconcile.model', 'account.fiscal.position', 'account.tax', 'account.move', 'account.journal']