mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
@@ -40,8 +40,30 @@
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_fp_2" />
|
||||
</record>
|
||||
<!-- Customizable Desk -->
|
||||
<record id="mrp_bom_product_4" model="mrp.bom">
|
||||
|
||||
<!-- FP-3 -->
|
||||
<record id="mrp_bom_fp_3" model="mrp.bom">
|
||||
<field name="product_tmpl_id" ref="product_product_fp_3_product_template" />
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="sequence">5</field>
|
||||
</record>
|
||||
<record id="mrp_bom_fp_3_line_sf_3" model="mrp.bom.line">
|
||||
<field name="product_id" ref="product_product_sf_3" />
|
||||
<field name="product_qty">2</field>
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_fp_3" />
|
||||
</record>
|
||||
<record id="mrp_bom_fp_3_line_pp_3" model="mrp.bom.line">
|
||||
<field name="product_id" ref="product_product_pp_3" />
|
||||
<field name="product_qty">2</field>
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_fp_3" />
|
||||
</record>
|
||||
|
||||
<!-- Customizable Desk -->
|
||||
<record id="mrp_bom_product_4" model="mrp.bom">
|
||||
<field
|
||||
name="product_tmpl_id"
|
||||
ref="product.product_product_4_product_template"
|
||||
@@ -126,4 +148,25 @@
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_sf_2" />
|
||||
</record>
|
||||
<!-- SF-3 -->
|
||||
<record id="mrp_bom_sf_3" model="mrp.bom">
|
||||
<field name="product_tmpl_id" ref="product_product_sf_3_product_template" />
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="type">phantom</field>
|
||||
<field name="sequence">5</field>
|
||||
</record>
|
||||
<record id="mrp_bom_sf_3_line_pp_3" model="mrp.bom.line">
|
||||
<field name="product_id" ref="product_product_pp_3" />
|
||||
<field name="product_qty">1</field>
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_sf_3" />
|
||||
</record>
|
||||
<record id="mrp_bom_sf_3_line_pp_4" model="mrp.bom.line">
|
||||
<field name="product_id" ref="product_product_pp_4" />
|
||||
<field name="product_qty">3</field>
|
||||
<field name="product_uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="sequence">5</field>
|
||||
<field name="bom_id" ref="mrp_bom_sf_3" />
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
<field name="product_id" ref="product_product_fp_2" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_fp_3" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_fp_3" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_product_4" model="product.mrp.area">
|
||||
<field name="product_id" ref="product.product_product_4" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
@@ -32,6 +36,10 @@
|
||||
<field name="product_id" ref="product_product_sf_2" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_sf_3" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_sf_3" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_pp_1" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_pp_1" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
@@ -40,6 +48,14 @@
|
||||
<field name="product_id" ref="product_product_pp_2" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_pp_3" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_pp_3" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_pp_4" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_pp_4" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
</record>
|
||||
<record id="product_mrp_area_av_11" model="product.mrp.area">
|
||||
<field name="product_id" ref="product_product_av_11" />
|
||||
<field name="mrp_area_id" ref="mrp_area_stock_wh0" />
|
||||
|
||||
@@ -24,7 +24,20 @@
|
||||
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||
/>
|
||||
</record>
|
||||
<!-- Customizable Desk -->
|
||||
<record id="product_product_fp_3" model="product.product">
|
||||
<field name="name">FP-3</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
<field name="type">product</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||
<field name="produce_delay">3</field>
|
||||
<field
|
||||
name="route_ids"
|
||||
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||
/>
|
||||
</record>
|
||||
|
||||
<!-- Customizable Desk -->
|
||||
<record id="product.product_product_4_product_template" model="product.template">
|
||||
<field
|
||||
name="route_ids"
|
||||
@@ -55,6 +68,19 @@
|
||||
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||
/>
|
||||
</record>
|
||||
<record id="product_product_sf_3" model="product.product">
|
||||
<field name="name">SF-3</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
<field name="type">product</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||
<field name="produce_delay">3</field>
|
||||
<field
|
||||
name="route_ids"
|
||||
eval="[(6, 0, [ref('mrp.route_warehouse0_manufacture')])]"
|
||||
/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_pp_1" model="product.product">
|
||||
<field name="name">PP-1</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
@@ -77,6 +103,31 @@
|
||||
eval="[(6, 0, [ref('purchase_stock.route_warehouse0_buy')])]"
|
||||
/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_pp_3" model="product.product">
|
||||
<field name="name">PP-3</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
<field name="type">product</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||
<field
|
||||
name="route_ids"
|
||||
eval="[(6, 0, [ref('purchase_stock.route_warehouse0_buy')])]"
|
||||
/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_pp_4" model="product.product">
|
||||
<field name="name">PP-4</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
<field name="type">product</field>
|
||||
<field name="uom_id" ref="uom.product_uom_unit" />
|
||||
<field name="uom_po_id" ref="uom.product_uom_unit" />
|
||||
<field
|
||||
name="route_ids"
|
||||
eval="[(6, 0, [ref('purchase_stock.route_warehouse0_buy')])]"
|
||||
/>
|
||||
</record>
|
||||
|
||||
<record id="product_product_av_11" model="product.product">
|
||||
<field name="name">AV-11 steel</field>
|
||||
<field name="categ_id" ref="product_category_mrp" />
|
||||
|
||||
@@ -42,4 +42,20 @@
|
||||
<field name="min_qty">0</field>
|
||||
<field name="price">100</field>
|
||||
</record>
|
||||
|
||||
<record id="product_supplierinfo_pp_3" model="product.supplierinfo">
|
||||
<field name="product_tmpl_id" ref="product_product_pp_3_product_template" />
|
||||
<field name="name" ref="res_partner_lazer_tech" />
|
||||
<field name="delay">2</field>
|
||||
<field name="min_qty">0</field>
|
||||
<field name="price">10</field>
|
||||
</record>
|
||||
|
||||
<record id="product_supplierinfo_pp_4" model="product.supplierinfo">
|
||||
<field name="product_tmpl_id" ref="product_product_pp_4_product_template" />
|
||||
<field name="name" ref="res_partner_lazer_tech" />
|
||||
<field name="delay">3</field>
|
||||
<field name="min_qty">0</field>
|
||||
<field name="price">80</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -78,6 +78,7 @@ class ProductMRPArea(models.Model):
|
||||
("buy", "Buy"),
|
||||
("none", "Undefined"),
|
||||
("manufacture", "Produce"),
|
||||
("phantom", "Kit"),
|
||||
("pull", "Pull From"),
|
||||
("push", "Push To"),
|
||||
("pull_push", "Pull & Push"),
|
||||
@@ -182,7 +183,14 @@ class ProductMRPArea(models.Model):
|
||||
"company_id": rec.mrp_area_id.company_id,
|
||||
}
|
||||
rule = group_obj._get_rule(rec.product_id, proc_loc, values)
|
||||
rec.supply_method = rule.action if rule else "none"
|
||||
if (
|
||||
rule.action == "manufacture"
|
||||
and rec.product_id.product_tmpl_id.bom_ids
|
||||
and rec.product_id.product_tmpl_id.bom_ids[0].type == "phantom"
|
||||
):
|
||||
rec.supply_method = "phantom"
|
||||
else:
|
||||
rec.supply_method = rule.action if rule else "none"
|
||||
|
||||
@api.depends(
|
||||
"mrp_area_id", "supply_method", "product_id.route_ids", "product_id.seller_ids"
|
||||
@@ -265,7 +273,4 @@ class ProductMRPArea(models.Model):
|
||||
|
||||
def _to_be_exploded(self):
|
||||
self.ensure_one()
|
||||
if self.supply_method == "manufacture":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return self.supply_method in ["manufacture", "phantom"]
|
||||
|
||||
@@ -28,10 +28,14 @@ class TestMrpMultiLevelCommon(SavepointCase):
|
||||
|
||||
cls.fp_1 = cls.env.ref("mrp_multi_level.product_product_fp_1")
|
||||
cls.fp_2 = cls.env.ref("mrp_multi_level.product_product_fp_2")
|
||||
cls.fp_3 = cls.env.ref("mrp_multi_level.product_product_fp_3")
|
||||
cls.sf_1 = cls.env.ref("mrp_multi_level.product_product_sf_1")
|
||||
cls.sf_2 = cls.env.ref("mrp_multi_level.product_product_sf_2")
|
||||
cls.sf_3 = cls.env.ref("mrp_multi_level.product_product_sf_3")
|
||||
cls.pp_1 = cls.env.ref("mrp_multi_level.product_product_pp_1")
|
||||
cls.pp_2 = cls.env.ref("mrp_multi_level.product_product_pp_2")
|
||||
cls.pp_3 = cls.env.ref("mrp_multi_level.product_product_pp_3")
|
||||
cls.pp_4 = cls.env.ref("mrp_multi_level.product_product_pp_4")
|
||||
cls.product_4b = cls.env.ref("product.product_product_4b")
|
||||
cls.av_11 = cls.env.ref("mrp_multi_level.product_product_av_11")
|
||||
cls.av_12 = cls.env.ref("mrp_multi_level.product_product_av_12")
|
||||
@@ -271,6 +275,19 @@ class TestMrpMultiLevelCommon(SavepointCase):
|
||||
"location_dest_id": cls.customer_location.id,
|
||||
},
|
||||
),
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"name": "Test move fp-3",
|
||||
"product_id": cls.fp_3.id,
|
||||
"date": date_move,
|
||||
"product_uom": cls.fp_3.uom_id.id,
|
||||
"product_uom_qty": 5,
|
||||
"location_id": cls.stock_location.id,
|
||||
"location_dest_id": cls.customer_location.id,
|
||||
},
|
||||
),
|
||||
(
|
||||
0,
|
||||
0,
|
||||
|
||||
@@ -389,3 +389,42 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
|
||||
self.assertEqual(len(prod_uom_test_inventory_lines), 1)
|
||||
self.assertEqual(prod_uom_test_inventory_lines.supply_qty, 12.0)
|
||||
# Supply qty has to be 12 has a dozen of units are in a RFQ.
|
||||
|
||||
def test_16_phantom_comp_planning(self):
|
||||
"""
|
||||
Phantom components will not appear in MRP Inventory or Planned Orders.
|
||||
MRP Parameter will have 'phantom' supply method.
|
||||
"""
|
||||
# SF-3
|
||||
sf_3_line_1 = self.mrp_inventory_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.sf_3.id)]
|
||||
)
|
||||
self.assertEqual(len(sf_3_line_1), 0)
|
||||
sf_3_planned_order_1 = self.planned_order_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.sf_3.id)]
|
||||
)
|
||||
self.assertEqual(len(sf_3_planned_order_1), 0)
|
||||
sf_3_mrp_parameter = self.product_mrp_area_obj.search(
|
||||
[("product_id", "=", self.sf_3.id)]
|
||||
)
|
||||
self.assertEqual(sf_3_mrp_parameter.supply_method, "phantom")
|
||||
# PP-3
|
||||
pp_3_line_1 = self.mrp_inventory_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.pp_3.id)]
|
||||
)
|
||||
self.assertEqual(len(pp_3_line_1), 1)
|
||||
self.assertEqual(pp_3_line_1.demand_qty, 20.0)
|
||||
pp_3_planned_orders = self.planned_order_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.pp_3.id)]
|
||||
)
|
||||
self.assertEqual(len(pp_3_planned_orders), 2)
|
||||
# PP-4
|
||||
pp_4_line_1 = self.mrp_inventory_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.pp_4.id)]
|
||||
)
|
||||
self.assertEqual(len(pp_4_line_1), 1)
|
||||
self.assertEqual(pp_4_line_1.demand_qty, 30.0)
|
||||
pp_4_planned_orders = self.planned_order_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.pp_4.id)]
|
||||
)
|
||||
self.assertEqual(len(pp_4_planned_orders), 1)
|
||||
|
||||
@@ -121,7 +121,15 @@ class MultiLevelMrp(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _prepare_mrp_move_data_bom_explosion(
|
||||
self, product, bomline, qty, mrp_date_demand_2, bom, name, planned_order
|
||||
self,
|
||||
product,
|
||||
bomline,
|
||||
qty,
|
||||
mrp_date_demand_2,
|
||||
bom,
|
||||
name,
|
||||
planned_order,
|
||||
values=None,
|
||||
):
|
||||
product_mrp_area = self._get_product_mrp_area_from_product_and_area(
|
||||
bomline.product_id, product.mrp_area_id
|
||||
@@ -157,7 +165,7 @@ class MultiLevelMrp(models.TransientModel):
|
||||
).replace(
|
||||
"Demand Bom Explosion: Demand Bom Explosion: ", "Demand Bom Explosion: "
|
||||
),
|
||||
"origin": planned_order.origin,
|
||||
"origin": planned_order.origin if planned_order else values.get("origin"),
|
||||
}
|
||||
|
||||
@api.model
|
||||
@@ -182,7 +190,9 @@ class MultiLevelMrp(models.TransientModel):
|
||||
return mrp_action_date, mrp_date_supply
|
||||
|
||||
@api.model
|
||||
def explode_action(self, product_mrp_area_id, mrp_action_date, name, qty, action):
|
||||
def explode_action(
|
||||
self, product_mrp_area_id, mrp_action_date, name, qty, action, values=None
|
||||
):
|
||||
"""Explode requirements."""
|
||||
mrp_date_demand = mrp_action_date
|
||||
if mrp_date_demand < date.today():
|
||||
@@ -221,6 +231,7 @@ class MultiLevelMrp(models.TransientModel):
|
||||
bom,
|
||||
name,
|
||||
action,
|
||||
values,
|
||||
)
|
||||
mrpmove_id2 = self.env["mrp.move"].create(move_data)
|
||||
if hasattr(action, "mrp_move_down_ids"):
|
||||
@@ -265,12 +276,20 @@ class MultiLevelMrp(models.TransientModel):
|
||||
order_data = self._prepare_planned_order_data(
|
||||
product_mrp_area_id, qty, mrp_date_supply, mrp_action_date, name, values
|
||||
)
|
||||
planned_order = self.env["mrp.planned.order"].create(order_data)
|
||||
# Do not create planned order for products that are Kits
|
||||
planned_order = False
|
||||
if not product_mrp_area_id.supply_method == "phantom":
|
||||
planned_order = self.env["mrp.planned.order"].create(order_data)
|
||||
qty_ordered = qty_ordered + qty
|
||||
|
||||
if product_mrp_area_id._to_be_exploded():
|
||||
self.explode_action(
|
||||
product_mrp_area_id, mrp_action_date, name, qty, planned_order
|
||||
product_mrp_area_id,
|
||||
mrp_action_date,
|
||||
name,
|
||||
qty,
|
||||
planned_order,
|
||||
values,
|
||||
)
|
||||
|
||||
values["qty_ordered"] = qty_ordered
|
||||
@@ -769,8 +788,13 @@ class MultiLevelMrp(models.TransientModel):
|
||||
|
||||
for product_mrp_area in product_mrp_area_ids:
|
||||
# Build the time-phased inventory
|
||||
if self._exclude_from_mrp(
|
||||
product_mrp_area.product_id, product_mrp_area.mrp_area_id
|
||||
# Condition "supply_method == phantom" is not added in _exclude_from_mrp
|
||||
# because this function is also used to filter the explosion.
|
||||
if (
|
||||
self._exclude_from_mrp(
|
||||
product_mrp_area.product_id, product_mrp_area.mrp_area_id
|
||||
)
|
||||
or product_mrp_area.supply_method == "phantom"
|
||||
):
|
||||
continue
|
||||
self._init_mrp_inventory(product_mrp_area)
|
||||
|
||||
Reference in New Issue
Block a user