summaryrefslogtreecommitdiff
path: root/addons/stock/tests
diff options
context:
space:
mode:
authorTiffany Chang (tic) <tic@odoo.com>2020-06-08 08:28:30 +0000
committerTiffany Chang (tic) <tic@odoo.com>2020-06-18 08:33:22 +0000
commitd25d320e0e870980971de945719f7b7d5deadd3c (patch)
treeaf0cce47127e35712e1035cea776e0f4005ccfab /addons/stock/tests
parent943ee2807083a436f83c3492dc36dadb1e34d24a (diff)
[IMP] mrp,(purchase_)stock: allow replenishment with only stock module
This commit makes it so products can be replenished without any other module. This is achieved by adding a "pull" rule to the default receipt route generated when a warehouse is created. "Pull" rule is added to 1-, 2-, and 3-step receipt routes. Previous to this commit, an additional module (e.g. purchase, mrp, etc.) was needed for a pull rule to trigger with the existing receipt route rules. Replenishments can be triggered via "Replenish" button in product form, recording rules (auto trigger), and replenishment (manual trigger). Additionally, this commit makes it so when other modules (mrp, purchase) that handle replenishment are installed, this additional "pull" rule is removed from the default receipt route to prevent undesired behavior (e.g. MTO manufacturing components magically being received from no where). Unfortunately this means 2 undesirable situations: 1. If a user adds adds/changes rules to the receipt route and then installs mrp or purchase then their additions/changes will be removed. 2. If a user removes either (when only 1 installed) or both of these modules then stock module will again not be able to replenish as the pull rule will not be re-added to the receipt route. It is expected that these 2 cases do not need to be handled in most cases or can be handled by advanced users. Stock tests have also been updated to accomodate this new pull rule. Specification 4 of overall inventory onboarding improvement task. Task: 2220129 Related Enterprise PR: odoo/enterprise#10719
Diffstat (limited to 'addons/stock/tests')
-rw-r--r--addons/stock/tests/test_proc_rule.py21
-rw-r--r--addons/stock/tests/test_stock_flow.py5
2 files changed, 13 insertions, 13 deletions
diff --git a/addons/stock/tests/test_proc_rule.py b/addons/stock/tests/test_proc_rule.py
index cababaebeef..190eaa25cfc 100644
--- a/addons/stock/tests/test_proc_rule.py
+++ b/addons/stock/tests/test_proc_rule.py
@@ -176,16 +176,17 @@ class TestProcRule(TransactionCase):
orderpoint_form.product_max_qty = 5.0
orderpoint = orderpoint_form.save()
- self.env['stock.rule'].create({
- 'name': 'Rule Supplier',
- 'route_id': warehouse.reception_route_id.id,
- 'location_id': warehouse.lot_stock_id.id,
- 'location_src_id': self.env.ref('stock.stock_location_suppliers').id,
- 'action': 'pull',
- 'delay': 9.0,
- 'procure_method': 'make_to_stock',
- 'picking_type_id': warehouse.in_type_id.id,
- })
+ # get auto-created pull rule from when warehouse is created
+ rule = self.env['stock.rule'].search([
+ ('route_id', '=', warehouse.reception_route_id.id),
+ ('location_id', '=', warehouse.lot_stock_id.id),
+ ('location_src_id', '=', self.env.ref('stock.stock_location_suppliers').id),
+ ('action', '=', 'pull'),
+ ('procure_method', '=', 'make_to_stock'),
+ ('picking_type_id', '=', warehouse.in_type_id.id)])
+
+ # add a delay [i.e. lead days] so procurement will be triggered based on forecasted stock
+ rule.delay = 9.0
delivery_move = self.env['stock.move'].create({
'name': 'Delivery',
diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py
index e1dc46edb4f..e5e301d723b 100644
--- a/addons/stock/tests/test_stock_flow.py
+++ b/addons/stock/tests/test_stock_flow.py
@@ -1723,8 +1723,7 @@ class TestStockFlow(TestStockCommon):
'location_id': self.stock_location,
'location_dest_id': self.customer_location})
- with self.assertRaises(UserError):
- move_mto_alone._action_confirm()
+ move_mto_alone._action_confirm()
move_with_ancestors._action_confirm()
other_move._action_confirm()
@@ -1732,7 +1731,7 @@ class TestStockFlow(TestStockCommon):
move_with_ancestors._do_unreserve()
other_move._do_unreserve()
- self.assertEqual(move_mto_alone.state, "draft")
+ self.assertEqual(move_mto_alone.state, "waiting")
self.assertEqual(move_with_ancestors.state, "waiting")
self.assertEqual(other_move.state, "confirmed")