[MIG] mrp_production_picking_type_from_route: Migration to 17.0

This commit is contained in:
Meritxell Abellan
2025-01-03 10:33:13 +01:00
parent 66cb1ec1b5
commit 2035f3bf1c
3 changed files with 19 additions and 22 deletions

View File

@@ -3,7 +3,7 @@
{
"name": "MRP Production Picking Type From Route",
"summary": "Updates the operation type creating MO based on the product",
"version": "15.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Manufacture",
"website": "https://github.com/OCA/manufacture",
"author": "ForgeFlow, Odoo Community Association (OCA)",

View File

@@ -7,23 +7,20 @@ from odoo import api, models
class MrpProduction(models.Model):
_inherit = "mrp.production"
# Skip picking_type_id as a onchange trigger, even though the
# extended method is an onchange for picking_type_id too.
# If triggered also from picking_type_id changes, it would be impossible
# to adjust picking_type_id manually.
@api.onchange("product_id", "company_id")
def _onchange_product_id(self):
res = super()._onchange_product_id()
if self.product_id:
base_domain = [
("action", "=", "manufacture"),
"|",
("company_id", "=", False),
("company_id", "child_of", self.company_id.id),
]
res_rule = self.env["procurement.group"]._search_rule(
False, False, self.product_id, False, base_domain
)
if res_rule:
self.picking_type_id = res_rule.picking_type_id
@api.depends("company_id", "bom_id", "product_id")
def _compute_picking_type_id(self):
res = super()._compute_picking_type_id()
for mo in self:
if mo.product_id:
base_domain = [
("action", "=", "manufacture"),
"|",
("company_id", "=", False),
("company_id", "child_of", mo.company_id.id),
]
res_rule = self.env["procurement.group"]._search_rule(
False, False, mo.product_id, False, base_domain
)
if res_rule:
mo.picking_type_id = res_rule.picking_type_id
return res

View File

@@ -10,7 +10,7 @@ class MrpProductionCase(TransactionCase):
super().setUp()
self.product_model = self.env["product.product"]
self.bom_model = self.env["mrp.bom"]
self.route_model = self.env["stock.location.route"]
self.route_model = self.env["stock.route"]
self.loc_model = self.env["stock.location"]
self.op_type_model = self.env["stock.picking.type"]
@@ -50,7 +50,7 @@ class MrpProductionCase(TransactionCase):
"action": "manufacture",
"picking_type_id": self.op_type_2.id,
"location_src_id": self.source_loc_2.id,
"location_id": self.wh.lot_stock_id.id,
"location_dest_id": self.wh.lot_stock_id.id,
},
)
],