From d87a108defe616b442a43da44d53c6a2f3910d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 4 Sep 2026 22:07:25 +0200 Subject: [PATCH] Add companies and employees to the user context This allows to use the context for domain to restrict to allowed companies and employees. --- modules/company/CHANGELOG | 1 + modules/company/res.py | 11 ++--------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/company/CHANGELOG b/modules/company/CHANGELOG index b9b0e58c6c..92fd7719c2 100644 --- a/modules/company/CHANGELOG +++ b/modules/company/CHANGELOG @@ -1,3 +1,4 @@ +* Add companies and employees to the user context Version 8.0.0 - 2026-04-20 -------------------------- diff --git a/modules/company/res.py b/modules/company/res.py index eacecef327..b0a94447d5 100644 --- a/modules/company/res.py +++ b/modules/company/res.py @@ -85,7 +85,9 @@ class User(metaclass=PoolMeta): def __setup__(cls): super().__setup__() cls._context_fields.insert(0, 'company') + cls._context_fields.insert(0, 'companies') cls._context_fields.insert(0, 'employee') + cls._context_fields.insert(0, 'employees') cls._context_fields.insert(0, 'company_filter') @classmethod @@ -148,15 +150,6 @@ class User(metaclass=PoolMeta): if len(employees) == 1: self.employee, = employees - @classmethod - def _get_preferences(cls, user, context_only=False): - res = super()._get_preferences(user, - context_only=context_only) - if not context_only: - res['companies'] = [c.id for c in user.companies] - res['employees'] = [e.id for e in user.employees] - return res - @classmethod def get_companies(cls): '''