summaryrefslogtreecommitdiff
path: root/addons/mrp_subcontracting
diff options
context:
space:
mode:
authorTiffany Chang (tic) <tic@odoo.com>2020-08-20 10:53:38 +0000
committerTiffany Chang (tic) <tic@odoo.com>2020-09-09 07:15:25 +0000
commit2688cd1bae489b1dec8862f4de727ac20514844c (patch)
tree100df8853bbd5e5664eedb4187936bbeede4ddad /addons/mrp_subcontracting
parentf0da27e7eb474e6db4cd999306c420804aaa6f9b (diff)
[IMP] mrp(_subcontracting), stock: MO reserve and replenish automatically
This commit does 3 things: 1. When 'action_confirm' is triggered in a manufacturing order, any 'move_raw_ids' (components) that are unable to be fully reserved when `action_assign` is triggered will be checked for an automatic reordering rule (RR). If a rule exists it will be auto-triggered. This includes subcontractor manufacturing orders. Relevant test updated to match this. 2. When a MO is completed, auto check if there are corresponding confirmed stock moves that can be populated by the completed products and trigger their 'action_assign' to reserve the completed products. 3. If a new move line is added to an already confirmed MO, then do same auto-RR check/trigger. (note will occur for pickings without extra code since `stock_picking.action_confirm` is triggered again in this case.) This reuses similar logic as odoo/odoo#52433 from task 2244230. Originally this was done in the `action_assign`, but has been moved to `action_confirm` so as to imitate the now archived MTO process with RR. Overlapping logic has been moved into stock_move for easier reusability. Note that this now means editing existing moves' `product_uom_qty` (i.e. Demand) will not have a flow to auto-trigger their RR. Subcontracting test updated to match + new mrp test added for this new feature. closes odoo/odoo#57174 Task: 2322496 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/mrp_subcontracting')
-rw-r--r--addons/mrp_subcontracting/tests/test_subcontracting.py14
1 files changed, 2 insertions, 12 deletions
diff --git a/addons/mrp_subcontracting/tests/test_subcontracting.py b/addons/mrp_subcontracting/tests/test_subcontracting.py
index 4c58db4659b..88e21407ff2 100644
--- a/addons/mrp_subcontracting/tests/test_subcontracting.py
+++ b/addons/mrp_subcontracting/tests/test_subcontracting.py
@@ -224,9 +224,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
def test_flow_4(self):
""" Tick "Manufacture" and "MTO" on the components and trigger the
creation of the subcontracting manufacturing order through a receipt
- picking. Checks that the delivery to the subcontractor is not created
- at the receipt creation. Then run the scheduler and check that
- the delivery and MO exist.
+ picking. Checks that the delivery and MO for its components are
+ automatically created.
"""
# Tick "manufacture" and MTO on self.comp2
mto_route = self.env.ref('stock.route_warehouse0_mto')
@@ -269,15 +268,6 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
('location_id', '=', warehouse.lot_stock_id.id),
('location_dest_id', '=', self.env.company.subcontracting_location_id.id)
])
- self.assertFalse(move)
-
- self.env['procurement.group'].run_scheduler(company_id=self.env.company.id)
-
- move = self.env['stock.move'].search([
- ('product_id', '=', self.comp2.id),
- ('location_id', '=', warehouse.lot_stock_id.id),
- ('location_dest_id', '=', self.env.company.subcontracting_location_id.id)
- ])
self.assertTrue(move)
picking_delivery = move.picking_id
self.assertTrue(picking_delivery)