summaryrefslogtreecommitdiff
path: root/addons/project_timesheet_holidays/models
diff options
context:
space:
mode:
authorLucas Lefèvre <lul@odoo.com>2019-07-16 13:22:12 +0000
committerYannick Tivisse <yti@odoo.com>2019-07-17 10:25:54 +0000
commit2e91d26194f71c70bfc0d9ca4fd3374deda9a768 (patch)
tree2cf1d745c924aa917e93359cb9c24541233a4b01 /addons/project_timesheet_holidays/models
parente2893ce3863ddf858ebee00096e06bbf010ddbc2 (diff)
[FIX] project_timesheet_holidays: Allow to create a company
It is currently impossible to create a company. The reason being that the newly created company is not yet in context `allowed_company_ids`. Therefore, every consequent access to a record protected with a multi company `ir.rule` fails for that company. Here, the module automatically creates a project in that company and later read that project to check a constraint. The read raises an AccessError, hence the company is not created. On the other hand, a user without project creation access rights but erp manager could want to create a company. It should work in that case too, as the project creation is transparent to the user and the project is archived. closes odoo/odoo#34920 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project_timesheet_holidays/models')
-rw-r--r--addons/project_timesheet_holidays/models/res_company.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/project_timesheet_holidays/models/res_company.py b/addons/project_timesheet_holidays/models/res_company.py
index 56b59e1b022..58307f874f0 100644
--- a/addons/project_timesheet_holidays/models/res_company.py
+++ b/addons/project_timesheet_holidays/models/res_company.py
@@ -28,7 +28,10 @@ class Company(models.Model):
@api.model
def create(self, values):
company = super(Company, self).create(values)
- company._create_leave_project_task()
+ # use sudo as the user could have the right to create a company
+ # but not to create a project. On the other hand, when the company
+ # is created, it is not in the allowed_company_ids on the env
+ company.sudo()._create_leave_project_task()
return company
def _create_leave_project_task(self):