mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
@@ -69,7 +69,7 @@ class MrpBomLine(models.Model):
|
||||
product_qty = values.get("product_qty") or lines.product_qty
|
||||
product_uom_id = values.get("product_uom_id")
|
||||
if product_uom_id:
|
||||
product_uom_id = self.env["product.uom"].browse(product_uom_id)
|
||||
product_uom_id = self.env["uom.uom"].browse(product_uom_id)
|
||||
product_uom_id = product_uom_id or lines.product_uom_id
|
||||
bom.message_post_with_view(
|
||||
"mrp_bom_tracking.track_bom_line_template",
|
||||
|
||||
@@ -14,6 +14,10 @@ class TestBomTracking(common.SavepointCase):
|
||||
cls.bom_obj = cls.env["mrp.bom"]
|
||||
cls.bom_line_obj = cls.env["mrp.bom.line"]
|
||||
|
||||
# Define UoM:
|
||||
cls.uom_unit_id = cls.env.ref("uom.product_uom_unit").id
|
||||
cls.uom_dozen_id = cls.env.ref("uom.product_uom_dozen").id
|
||||
|
||||
# Create products:
|
||||
cls.product_1 = cls.product_obj.create({"name": "TEST 01", "type": "product"})
|
||||
cls.component_1 = cls.product_obj.create({"name": "RM 01", "type": "product"})
|
||||
@@ -27,10 +31,20 @@ class TestBomTracking(common.SavepointCase):
|
||||
{"product_tmpl_id": cls.product_1.product_tmpl_id.id}
|
||||
)
|
||||
cls.line_1 = cls.bom_line_obj.create(
|
||||
{"product_id": cls.component_1.id, "bom_id": cls.bom.id, "product_qty": 2.0}
|
||||
{
|
||||
"product_id": cls.component_1.id,
|
||||
"bom_id": cls.bom.id,
|
||||
"product_qty": 2.0,
|
||||
"product_uom_id": cls.uom_unit_id,
|
||||
}
|
||||
)
|
||||
cls.line_2 = cls.bom_line_obj.create(
|
||||
{"product_id": cls.component_2.id, "bom_id": cls.bom.id, "product_qty": 5.0}
|
||||
{
|
||||
"product_id": cls.component_2.id,
|
||||
"bom_id": cls.bom.id,
|
||||
"product_qty": 5.0,
|
||||
"product_uom_id": cls.uom_unit_id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_01_change_bom_line_qty(self):
|
||||
@@ -44,3 +58,9 @@ class TestBomTracking(common.SavepointCase):
|
||||
self.line_2.product_id = self.component_2_alt
|
||||
after = self.bom.message_ids
|
||||
self.assertEqual(len(after - before), 1)
|
||||
|
||||
def test_03_change_bom_line_uom(self):
|
||||
before = self.bom.message_ids
|
||||
self.line_1.product_uom_id = self.uom_dozen_id
|
||||
after = self.bom.message_ids
|
||||
self.assertEqual(len(after - before), 1)
|
||||
|
||||
Reference in New Issue
Block a user