oca-hr/odoo-bringout-oca-hr-hr_employee_document/hr_employee_document/models/ir_rule.py
Ernad Husremovic dfcda4100c Move all OCA HR modules from oca-technical to dedicated oca-hr submodule
Reorganized 67 HR-related modules for better structure:
- Moved all odoo-bringout-oca-hr-* packages from packages/oca-technical/
- Now organized in dedicated packages/oca-hr/ submodule
- Includes attendance, expense, holiday, employee, and contract modules
- Maintains all module functionality while improving project organization

This creates a cleaner separation between general technical modules
and HR-specific functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:11:28 +02:00

36 lines
1.2 KiB
Python

# Copyright 2023 Tecnativa - Víctor Martínez
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from odoo import api, models, tools
from odoo.osv import expression
from odoo.tools import config
class IrRule(models.Model):
_inherit = "ir.rule"
@api.model
@tools.conditional(
"xml" not in config["dev_mode"],
tools.ormcache(
"self.env.uid",
"self.env.su",
"model_name",
"mode",
"tuple(self._compute_domain_context_values())",
),
)
def _compute_domain(self, model_name, mode="read"):
"""We need to add for security purposes an extra domain in the hr.employee
model to restrict only the user's employees when search employee attachments."""
res = super()._compute_domain(model_name, mode=mode)
user = self.env.user
if (
model_name == "hr.employee"
and not self.env.su
and not user.has_group("hr.group_hr_manager")
and self.env.context.get("search_attachments_from_hr_employee")
):
extra_domain = [[("id", "in", user.employee_ids.ids)]]
res = expression.AND(extra_domain + [res])
return res