mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[MIG] mrp_production_picking_type_from_route: Migration to 17.0
This commit is contained in:
@@ -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)",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user