[FIX] analytic: can't create plan with access.

You should be able to create analytic plans with analytic group.
But currently, you need Access Right's group.
We should put a sudo there.

closes odoo/odoo#151328

Signed-off-by: Habib Ayob (ayh) <ayh@odoo.com>
This commit is contained in:
Gauthier Wala (gawa)
2024-02-07 09:18:50 +00:00
parent b097f20921
commit 59aae9767f
+2 -2
View File
@@ -246,7 +246,7 @@ class AccountAnalyticPlan(models.Model):
return super().unlink()
def _find_plan_column(self):
return self.env['ir.model.fields'].search([
return self.env['ir.model.fields'].sudo().search([
('name', 'in', [plan._strict_column_name() for plan in self]),
('model', '=', 'account.analytic.line'),
])
@@ -261,7 +261,7 @@ class AccountAnalyticPlan(models.Model):
prev.field_description = plan.name
elif not plan.parent_id:
column = plan._strict_column_name()
self.env['ir.model.fields'].with_context(update_custom_fields=True).create({
self.env['ir.model.fields'].with_context(update_custom_fields=True).sudo().create({
'name': column,
'field_description': plan.name,
'state': 'manual',