feat: add stock dependency and dynamically update stock record rules for multi-company access
This commit is contained in:
parent
971f004a26
commit
9e0e5ad977
@ -8,7 +8,7 @@
|
|||||||
It allows an employee to be associated with multiple branch companies.
|
It allows an employee to be associated with multiple branch companies.
|
||||||
""",
|
""",
|
||||||
'author': 'Suherdy Yacob',
|
'author': 'Suherdy Yacob',
|
||||||
'depends': ['hr', 'pos_hr', 'hr_attendance', 'product'],
|
'depends': ['hr', 'pos_hr', 'hr_attendance', 'product', 'stock'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/hr_security.xml',
|
'security/hr_security.xml',
|
||||||
'security/hr_attendance_security.xml',
|
'security/hr_attendance_security.xml',
|
||||||
|
|||||||
Binary file not shown.
@ -28,6 +28,33 @@ class HrEmployee(models.Model):
|
|||||||
domain="[('share', '=', False), ('company_ids', 'in', company_ids)]"
|
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
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
employees = super().create(vals_list)
|
employees = super().create(vals_list)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user