mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[14.0][FIX] mrp_sale_info: Fix regression introduced by #1009 resulting in AttributeError when values.get("move_dest_ids") is None. This happens for example when manufacturing order is not created from a sale order but from an orderpoint. A test case was added to cover this occurrence.
This commit is contained in:
@@ -41,4 +41,6 @@ class StockRule(models.Model):
|
|||||||
moves = moves.move_dest_ids
|
moves = moves.move_dest_ids
|
||||||
line_ids |= moves.sale_line_id
|
line_ids |= moves.sale_line_id
|
||||||
res["sale_line_ids"] = line_ids and [(4, x.id) for x in line_ids] or False
|
res["sale_line_ids"] = line_ids and [(4, x.id) for x in line_ids] or False
|
||||||
|
return res # eg in case of orderpoint generating MO
|
||||||
|
line_ids = moves.sale_line_id
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -21,9 +21,15 @@ class TestMrpSaleInfo(common.SavepointCase):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
cls.product_to_use = cls.env["product.product"].create(
|
||||||
|
{"name": "Material", "type": "product"}
|
||||||
|
)
|
||||||
cls.bom = cls.env["mrp.bom"].create(
|
cls.bom = cls.env["mrp.bom"].create(
|
||||||
{
|
{
|
||||||
"product_tmpl_id": cls.product.product_tmpl_id.id,
|
"product_tmpl_id": cls.product.product_tmpl_id.id,
|
||||||
|
"bom_line_ids": [
|
||||||
|
(0, 0, {"product_id": cls.product_to_use.id, "product_qty": 1.0}),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
|
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
|
||||||
@@ -56,3 +62,24 @@ class TestMrpSaleInfo(common.SavepointCase):
|
|||||||
self.assertEqual(self.sale_order.mrp_production_count, 1)
|
self.assertEqual(self.sale_order.mrp_production_count, 1)
|
||||||
sale_action = self.sale_order.action_view_mrp_production()
|
sale_action = self.sale_order.action_view_mrp_production()
|
||||||
self.assertEqual(sale_action["res_id"], production.id)
|
self.assertEqual(sale_action["res_id"], production.id)
|
||||||
|
production.action_confirm()
|
||||||
|
|
||||||
|
def test_orderpoint(self):
|
||||||
|
"""Test if orderpoint MO generation still works well"""
|
||||||
|
prev_productions = self.env["mrp.production"].search([])
|
||||||
|
warehouse = self.env["stock.warehouse"].search([], limit=1)
|
||||||
|
orderpoint = self.env["stock.warehouse.orderpoint"].create(
|
||||||
|
{
|
||||||
|
"name": "replenish product",
|
||||||
|
"location_id": warehouse.lot_stock_id.id,
|
||||||
|
"product_id": self.product.id,
|
||||||
|
"product_min_qty": 10,
|
||||||
|
"product_max_qty": 100,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
orderpoint._procure_orderpoint_confirm(
|
||||||
|
company_id=orderpoint.company_id, raise_user_error=False
|
||||||
|
)
|
||||||
|
production = self.env["mrp.production"].search([]) - prev_productions
|
||||||
|
self.assertEqual(len(production), 1)
|
||||||
|
production.action_confirm()
|
||||||
|
|||||||
Reference in New Issue
Block a user