Skip to content

Commit

Permalink
TA#70584 [14.0][DEL] stock_location_production
Browse files Browse the repository at this point in the history
  • Loading branch information
abenzbiria committed Nov 1, 2024
1 parent ec8352b commit 72eecf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions project_material/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def post_init_hook(cr, registry):
def _setup_warehouses_consumption_routes(env):
warehouses = env["stock.warehouse"].search([])
for warehouse in warehouses:
location_id = env["ir.property"].with_company(
warehouse.company_id.id)._get(
"property_stock_production", "product.template")
warehouse.consu_location_id = location_id.id
warehouse.consu_location_id = warehouse._get_consu_location_id()
warehouse._create_or_update_consumption_picking_types()
warehouse._create_or_update_consumption_route()
10 changes: 10 additions & 0 deletions project_material/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def create(self, vals):
Use sudo to prevent errors related to access rights.
"""
warehouse = super().create(vals)

Check notice on line 53 in project_material/models/stock_warehouse.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

project_material/models/stock_warehouse.py#L53

Trailing whitespace
warehouse.consu_location_id = warehouse._get_consu_location_id()
warehouse.sudo()._create_consumption_picking_types()
warehouse.sudo()._create_consumption_route()
warehouse.sudo()._create_consumption_mto_pull()
Expand All @@ -63,10 +65,18 @@ def write(self, vals):
super().write(vals)
if "consu_steps" in vals:
for warehouse in self:
warehouse.consu_location_id = warehouse._get_consu_location_id()
warehouse.sudo()._create_or_update_consumption_picking_types()
warehouse.sudo()._create_or_update_consumption_route()
warehouse.sudo()._create_or_update_consumption_mto_pull()
return True

@api.model
def _get_consu_location_id(self):
location_id = self.env["ir.property"].with_company(
self.company_id.id)._get(
"property_stock_production","product.template").id
return location_id

def _create_or_update_consumption_picking_types(self):
self = self.with_company(self.company_id)
Expand Down

0 comments on commit 72eecf5

Please sign in to comment.