diff --git a/__manifest__.py b/__manifest__.py index 1c64679..ba8e071 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -8,7 +8,7 @@ It allows an employee to be associated with multiple branch companies. """, 'author': 'Suherdy Yacob', - 'depends': ['hr', 'pos_hr', 'hr_attendance', 'product'], + 'depends': ['hr', 'pos_hr', 'hr_attendance', 'product', 'stock'], 'data': [ 'security/hr_security.xml', 'security/hr_attendance_security.xml', diff --git a/models/__pycache__/hr_employee.cpython-312.pyc b/models/__pycache__/hr_employee.cpython-312.pyc index 4c07b77..433cc6d 100644 Binary files a/models/__pycache__/hr_employee.cpython-312.pyc and b/models/__pycache__/hr_employee.cpython-312.pyc differ diff --git a/models/hr_employee.py b/models/hr_employee.py index 252478d..a8a0766 100644 --- a/models/hr_employee.py +++ b/models/hr_employee.py @@ -28,6 +28,33 @@ class HrEmployee(models.Model): domain="[('share', '=', False), ('company_ids', 'in', company_ids)]" ) + @api.model + def _register_hook(self): + super()._register_hook() + rules_to_update = { + 'stock.stock_picking_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_picking_type_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_putaway_rule_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_production_lot_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_warehouse_comp_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_location_comp_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_move_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_move_line_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_quant_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_warehouse_orderpoint_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.product_pulled_flow_comp_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_location_route_comp_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_package_comp_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + 'stock.stock_scrap_company_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.report_stock_quantity_flow_comp_rule': "[('company_id', 'in', user.company_ids.ids)]", + 'stock.stock_storage_category_rule': "[('company_id', 'in', user.company_ids.ids + [False])]", + } + for xml_id, domain in rules_to_update.items(): + rule = self.env.ref(xml_id, raise_if_not_found=False) + if rule and rule.domain_force != domain: + rule.sudo().write({'domain_force': domain}) + + @api.model_create_multi def create(self, vals_list): employees = super().create(vals_list)