[FIX] mrp: carry over origin from source move in 3-step mfr

Behavior prior to this commit:

- when the warehouse uses a 3-step manufacturing process, if I create a
Sales Order, the MO generated does not show the SO# as "Source", instead
it shows the MO#

Behavior after this commit:

- the MO source shows the SO# (similar to how it works when using the
2-step or the 1-step manufacturing process)
- the origins are assigned thus:
  - Delivery Picking = SO name
  - Post-prod Picking = SO name
  - MO = SO name
  - Pre-prod Picking = MO name

Note:

- there is no implementation change in this commit - we just ported the
test from the original commit in 13.0 (the behavior in 14.0 was already
OK)

opw-2380717

closes odoo/odoo#62512

X-original-commit: 0281dee6da75e68403772ebd368d57c1feb98c37
Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
This commit is contained in:
Nicolas Galler
2020-11-27 11:13:33 +00:00
parent 608d3d87b2
commit f060e3df0a
@@ -150,11 +150,14 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
'location_id': self.warehouse.wh_output_stock_loc_id.id,
'location_dest_id': self.customer_location,
'procure_method': 'make_to_order',
'origin': 'SOURCEDOCUMENT',
'state': 'draft',
})
picking_customer.action_confirm()
production_order = self.env['mrp.production'].search([('product_id', '=', self.finished_product.id)])
self.assertTrue(production_order)
self.assertEqual(production_order.origin, 'SOURCEDOCUMENT', 'The MO origin should be the SO name')
self.assertNotEqual(production_order.name, 'SOURCEDOCUMENT', 'The MO name should not be the origin of the move')
picking_stock_preprod = self.env['stock.move'].search([
('product_id', '=', self.raw_product.id),
@@ -173,6 +176,8 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
self.assertTrue(picking_stock_postprod)
self.assertEqual(picking_stock_preprod.state, 'confirmed')
self.assertEqual(picking_stock_postprod.state, 'waiting')
self.assertEqual(picking_stock_preprod.origin, production_order.name, 'The pre-prod origin should be the MO name')
self.assertEqual(picking_stock_postprod.origin, 'SOURCEDOCUMENT', 'The post-prod origin should be the SO name')
picking_stock_preprod.action_assign()
picking_stock_preprod.move_line_ids.qty_done = 4