Files
odoo_source/addons/hr_timesheet/models/project_collaborator.py
T
Xavier BOL (xbo) cc87856017 [FIX] hr_timesheet: archive/unarchive ir.rule for project sharing
Before this commit, the ir.rule called `timesheet_line_rule_portal_user`
is added just for the project sharing and have to be unarchived when at
least an external collaborator is added into a project. But this rule is
never unarchived.

This commit archives/unarchives the ir rule when the condition is
satisfied.

part of task-2648955

closes odoo/odoo#81553

X-original-commit: a6f0aaeea8b621040559738d7b27d320b6208b58
Related: odoo/enterprise#22956
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
2021-12-16 18:25:04 +00:00

22 lines
838 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class ProjectCollaborator(models.Model):
_inherit = 'project.collaborator'
@api.model
def _toggle_project_sharing_portal_rules(self, active):
super()._toggle_project_sharing_portal_rules(active)
# ir.model.access
access_timesheet_portal = self.env.ref('hr_timesheet.access_account_analytic_line_portal_user').sudo()
if access_timesheet_portal.active != active:
access_timesheet_portal.write({'active': active})
# ir.rule
timesheet_portal_ir_rule = self.env.ref('hr_timesheet.timesheet_line_rule_portal_user').sudo()
if timesheet_portal_ir_rule.active != active:
timesheet_portal_ir_rule.write({'active': active})