diff --git a/shopfloor_base/services/service.py b/shopfloor_base/services/service.py index 5a84e23636c..8ecc68dc111 100644 --- a/shopfloor_base/services/service.py +++ b/shopfloor_base/services/service.py @@ -298,3 +298,25 @@ class BaseShopfloorProcess(AbstractComponent): _requires_header_menu = True _requires_header_profile = True + + def env_with_company(self, env): + if ( + not hasattr(self, "work") + or not hasattr(self.work, "menu") + or not hasattr(self.work.menu, "picking_type_ids") + ): + return env + company = self.work.menu.picking_type_ids.company_id + if not company: + return env + context = dict(self.collection.env.context) + context.update( + { + "allowed_company_ids": company.ids, + } + ) + return env(context=context) + + def _actions_for(self, usage, **kw): + self.collection.env = self.env_with_company(self.collection.env) + return super()._actions_for(usage, **kw)