mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] mrp_multi_level: Fix case when Purchase Uom is different from Uom and PO in draft
This commit is contained in:
committed by
Lois Rilo
parent
43106d8552
commit
1642fcd1ac
@@ -199,6 +199,22 @@ class TestMrpMultiLevelCommon(SavepointCase):
|
||||
cls.product_mrp_area_obj.create(
|
||||
{"product_id": cls.product_tz.id, "mrp_area_id": cls.cases_area.id}
|
||||
)
|
||||
# Product to test special case with Purchase Uom:
|
||||
cls.prod_uom_test = cls.product_obj.create(
|
||||
{
|
||||
"name": "Product Uom Test",
|
||||
"type": "product",
|
||||
"uom_id": cls.env.ref("uom.product_uom_unit").id,
|
||||
"uom_po_id": cls.env.ref("uom.product_uom_dozen").id,
|
||||
"list_price": 150.0,
|
||||
"produce_delay": 5.0,
|
||||
"route_ids": [(6, 0, [route_buy])],
|
||||
"seller_ids": [(0, 0, {"name": vendor1.id, "price": 20.0})],
|
||||
}
|
||||
)
|
||||
cls.product_mrp_area_obj.create(
|
||||
{"product_id": cls.prod_uom_test.id, "mrp_area_id": cls.mrp_area.id}
|
||||
)
|
||||
|
||||
# Create pickings for Scenario 1:
|
||||
dt_base = cls.calendar.plan_days(3 + 1, datetime.today())
|
||||
@@ -347,6 +363,30 @@ class TestMrpMultiLevelCommon(SavepointCase):
|
||||
],
|
||||
}
|
||||
)
|
||||
# Create Test PO for special case Puchase uom:
|
||||
# Remember that prod_uom_test had a UoM of units but it is purchased in dozens.
|
||||
# For this reason buying 1 quantity of it, means to have 12 units in stock.
|
||||
date_po = cls.calendar.plan_days(1 + 1, datetime.today().replace(hour=0)).date()
|
||||
cls.po_uom = cls.po_obj.create(
|
||||
{
|
||||
"name": "Test PO-002",
|
||||
"partner_id": cls.vendor.id,
|
||||
"order_line": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"name": "Product Uom Test line",
|
||||
"product_id": cls.prod_uom_test.id,
|
||||
"date_planned": date_po,
|
||||
"product_qty": 1.0,
|
||||
"product_uom": cls.prod_uom_test.uom_po_id.id,
|
||||
"price_unit": 25.0,
|
||||
},
|
||||
)
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
# Create test MO:
|
||||
date_mo = cls.calendar.plan_days(9 + 1, datetime.today().replace(hour=0)).date()
|
||||
|
||||
@@ -375,3 +375,13 @@ class TestMrpMultiLevel(TestMrpMultiLevelCommon):
|
||||
)
|
||||
self.assertEqual(len(inventory), 1)
|
||||
self.assertEqual(inventory.date, date_move.date())
|
||||
|
||||
def test_15_units_case(self):
|
||||
"""When a product has a different purchase unit of measure than
|
||||
the general unit of measure and the supply is coming from an RFQ"""
|
||||
prod_uom_test_inventory_lines = self.mrp_inventory_obj.search(
|
||||
[("product_mrp_area_id.product_id", "=", self.prod_uom_test.id)]
|
||||
)
|
||||
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.
|
||||
|
||||
@@ -384,8 +384,8 @@ class MultiLevelMrp(models.TransientModel):
|
||||
"purchase_order_id": poline.order_id.id,
|
||||
"purchase_line_id": poline.id,
|
||||
"stock_move_id": None,
|
||||
"mrp_qty": poline.product_qty,
|
||||
"current_qty": poline.product_qty,
|
||||
"mrp_qty": poline.product_uom_qty,
|
||||
"current_qty": poline.product_uom_qty,
|
||||
"mrp_date": mrp_date,
|
||||
"current_date": poline.date_planned,
|
||||
"mrp_type": "s",
|
||||
|
||||
Reference in New Issue
Block a user