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 4f4b551 commit a57ad79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 4 additions & 0 deletions project_material/init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ 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._create_or_update_consumption_picking_types()
warehouse._create_or_update_consumption_route()
15 changes: 1 addition & 14 deletions project_material/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ class Warehouse(models.Model):

_inherit = "stock.warehouse"

def _get_default_consumption_location_id(self):
property_stock_production = self.env['ir.property'].sudo().search(
[('name', '=', 'property_stock_production'),
('company_id', '=', self.env.company.id)])
location_id = property_stock_production.value_reference.split(',')[-1]
return location_id

consu_steps = fields.Selection(
[(ONE_STEP_KEY, ONE_STEP_DESCRIPTION)], default=ONE_STEP_KEY
)
Expand All @@ -32,27 +25,22 @@ def _has_one_step_consumption(self):
"Consumption Location",
domain=[("usage", "=", "production")],
ondelete="restrict",
default=_get_default_consumption_location_id, check_company=True
)

consu_type_id = fields.Many2one(
"stock.picking.type", "Consumption Picking Type", ondelete="restrict",
check_company=True
)

consu_return_type_id = fields.Many2one(
"stock.picking.type", "Consumption Return Picking Type", ondelete="restrict",
check_company=True
)

consu_route_id = fields.Many2one(
"stock.location.route", "Consumption Route", ondelete="restrict",
check_company=True
)

consu_mto_pull_id = fields.Many2one(
"stock.rule", "Consumption MTO Pull", ondelete="restrict",
check_company=True
)

@api.model
Expand Down Expand Up @@ -90,7 +78,6 @@ def _create_or_update_consumption_picking_types(self):
def _create_consumption_picking_types(self):
vals = self._get_consumption_picking_type_create_values()
self.consu_type_id = self.env["stock.picking.type"].create(vals)

vals = self._get_consumption_return_picking_type_create_values()
self.consu_return_type_id = self.env["stock.picking.type"].create(vals)

Expand Down Expand Up @@ -148,7 +135,7 @@ def _get_consumption_picking_type_values(self):
if self._has_one_step_consumption()
else self.consu_prep_location_id.id
),
"default_location_dest_id": self.consu_location_id.id,
"default_location_dest_id": self.with_company(self.company_id).consu_location_id.id,
}

def _get_consumption_return_picking_type_values(self):
Expand Down

0 comments on commit a57ad79

Please sign in to comment.