summaryrefslogtreecommitdiff
path: root/addons/purchase_stock/__init__.py
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/purchase_stock/__init__.py
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/purchase_stock/__init__.py')
-rw-r--r--addons/purchase_stock/__init__.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/addons/purchase_stock/__init__.py b/addons/purchase_stock/__init__.py
index 6fee2cb6173..849b2eb3699 100644
--- a/addons/purchase_stock/__init__.py
+++ b/addons/purchase_stock/__init__.py
@@ -14,5 +14,4 @@ def _create_buy_rules(cr, registry):
"""
env = api.Environment(cr, SUPERUSER_ID, {})
warehouse_ids = env['stock.warehouse'].search([('buy_pull_id', '=', False)])
- for warehouse_id in warehouse_ids:
- warehouse_id._create_or_update_global_routes_rules()
+ warehouse_ids.write({'buy_to_resupply': True})