Merge PR #1010 into 14.0

Signed-off-by sebastienbeau
This commit is contained in:
OCA-git-bot
2023-11-21 07:43:07 +00:00
2 changed files with 26 additions and 1 deletions

View File

@@ -33,5 +33,11 @@ class StockRule(models.Model):
if lot_id:
vals["lot_producing_id"] = lot_id
lot = self.env["stock.production.lot"].browse(lot_id)
vals["name"] = lot.name
mo_name = lot.name
existing_mo = self.env["mrp.production"].search(
[("lot_producing_id", "=", lot_id)]
)
if existing_mo:
mo_name = "%s-%s" % (mo_name, len(existing_mo))
vals["name"] = mo_name
return vals

View File

@@ -49,3 +49,22 @@ class TestRestrictLot(SavepointCase):
mo = move.move_orig_ids.production_id
self.assertEqual(mo.lot_producing_id.id, lot.id)
self.assertEqual(mo.name, lot.name)
group = self.env["procurement.group"].create({"name": "My test delivery 2"})
move = self.env["stock.move"].create(
{
"product_id": self.panel_wood_prd.id,
"location_id": self.warehouse.lot_stock_id.id,
"location_dest_id": self.customer_loc.id,
"product_uom_qty": 1,
"product_uom": self.panel_wood_prd.uom_id.id,
"name": "test",
"procure_method": "make_to_order",
"warehouse_id": self.warehouse.id,
"restrict_lot_id": lot.id,
"picking_type_id": self.out_picking_type.id,
"group_id": group.id,
}
)
move._action_confirm()
mo = move.move_orig_ids.production_id
self.assertEqual(mo.name, "%s-%s" % (lot.name, 1))