mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[TESTS] stock_available_mrp: Add test for phantom bom
This commit is contained in:
committed by
Víctor Martínez
parent
29a63ae105
commit
1562016235
@@ -404,3 +404,77 @@ class TestPotentialQty(SavepointCase):
|
|||||||
{p1.id: 3.0, p2.id: 3.0, p3.id: 0.0},
|
{p1.id: 3.0, p2.id: 3.0, p3.id: 0.0},
|
||||||
{p.id: p.potential_qty for p in products},
|
{p.id: p.potential_qty for p in products},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_product_phantom(self):
|
||||||
|
# Create a BOM product with 2 components
|
||||||
|
# Set stock quantity for the first one == 0.0
|
||||||
|
# Set stock quantity for the second one == 1.0
|
||||||
|
# Create an incoming movement for the first component
|
||||||
|
# The immediately available quantity should stay == 0.0
|
||||||
|
uom_unit = self.env.ref("uom.product_uom_unit")
|
||||||
|
uom_unit.rounding = 1.0
|
||||||
|
product = self.product_model.create(
|
||||||
|
{
|
||||||
|
"name": "Test product with BOM",
|
||||||
|
"type": "product",
|
||||||
|
"uom_id": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
bom = self.bom_model.create(
|
||||||
|
{
|
||||||
|
"product_tmpl_id": product.product_tmpl_id.id,
|
||||||
|
"product_id": product.id,
|
||||||
|
"type": "phantom",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
bom_product = self.product_model.create(
|
||||||
|
{
|
||||||
|
"name": "BOM product",
|
||||||
|
"type": "product",
|
||||||
|
"uom_id": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.bom_line_model.create(
|
||||||
|
{
|
||||||
|
"bom_id": bom.id,
|
||||||
|
"product_id": bom_product.id,
|
||||||
|
"product_qty": 1,
|
||||||
|
"product_uom_id": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
bom_product_2 = self.product_model.create(
|
||||||
|
{
|
||||||
|
"name": "BOM product 2",
|
||||||
|
"type": "product",
|
||||||
|
"uom_id": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.bom_line_model.create(
|
||||||
|
{
|
||||||
|
"bom_id": bom.id,
|
||||||
|
"product_id": bom_product_2.id,
|
||||||
|
"product_qty": 1,
|
||||||
|
"product_uom_id": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.create_inventory(bom_product_2.id, 1)
|
||||||
|
|
||||||
|
move_in = self.env["stock.move"].create(
|
||||||
|
{
|
||||||
|
"name": bom_product.name,
|
||||||
|
"location_id": self.env.ref("stock.stock_location_suppliers").id,
|
||||||
|
"location_dest_id": self.env.ref("stock.stock_location_stock").id,
|
||||||
|
"product_id": bom_product.id,
|
||||||
|
"product_uom_qty": 1.0,
|
||||||
|
"product_uom": self.env.ref("uom.product_uom_unit").id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
move_in._action_confirm()
|
||||||
|
product.invalidate_cache()
|
||||||
|
|
||||||
|
self.assertEqual(product.immediately_usable_qty, 0.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user