summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2019-08-06 08:10:51 +0000
committerArnold Moyaux <arm@odoo.com>2019-08-19 15:03:59 +0000
commit4d5ec8ff124894bb5d9a7df16e94e02855dbbe0f (patch)
tree4795c85e08fbf2831b0aa5d630a5021b976b8710 /addons
parentc3dc552185d9830ed2df528f36490c5478cfbc45 (diff)
[IMP] stock, mrp: remove MTO route magical behavior
When a move is created from a location A to a location B and not via a rule but it wants to apply the rule logic in order to know if a move is MTS or MTO then _adjust_procure_method is called. It will check if a rule between A and B for the selected product/ category/warehouse and if it exists it will apply the rule procure method to the move. If not it will check if the route MTO is ticked, and will set the move as MTO even if no rule exist. It could be miss understanding by the user that have moves MTO without matching rule. It would be easier to have a single proccess with rule.
Diffstat (limited to 'addons')
-rw-r--r--addons/mrp/models/stock_warehouse.py21
-rw-r--r--addons/stock/models/stock_move.py8
2 files changed, 21 insertions, 8 deletions
diff --git a/addons/mrp/models/stock_warehouse.py b/addons/mrp/models/stock_warehouse.py
index 40d6b6bb4b9..98e8cada056 100644
--- a/addons/mrp/models/stock_warehouse.py
+++ b/addons/mrp/models/stock_warehouse.py
@@ -13,6 +13,8 @@ class StockWarehouse(models.Model):
help="When products are manufactured, they can be manufactured in this warehouse.")
manufacture_pull_id = fields.Many2one(
'stock.rule', 'Manufacture Rule')
+ manufacture_mto_pull_id = fields.Many2one(
+ 'stock.rule', 'Manufacture MTO Rule')
pbm_mto_pull_id = fields.Many2one(
'stock.rule', 'Picking Before Manufacturing MTO Rule')
sam_rule_id = fields.Many2one(
@@ -101,6 +103,8 @@ class StockWarehouse(models.Model):
def _get_global_route_rules_values(self):
rules = super(StockWarehouse, self)._get_global_route_rules_values()
+ location_src = self.manufacture_steps == 'mrp_one_step' and self.lot_stock_id or self.pbm_loc_id
+ production_location = self._get_production_location()
location_id = self.manufacture_steps == 'pbm_sam' and self.sam_loc_id or self.lot_stock_id
rules.update({
'manufacture_pull_id': {
@@ -119,6 +123,23 @@ class StockWarehouse(models.Model):
'propagate_cancel': self.manufacture_steps == 'pbm_sam'
},
},
+ 'manufacture_mto_pull_id': {
+ 'depends': ['manufacture_steps', 'manufacture_to_resupply'],
+ 'create_values': {
+ 'procure_method': 'make_to_order',
+ 'company_id': self.company_id.id,
+ 'action': 'pull',
+ 'auto': 'manual',
+ 'route_id': self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id,
+ 'location_id': production_location.id,
+ 'location_src_id': location_src.id,
+ 'picking_type_id': self.manu_type_id.id
+ },
+ 'update_values': {
+ 'name': self._format_rulename(location_src, production_location, 'MTO'),
+ 'active': self.manufacture_to_resupply,
+ },
+ },
'pbm_mto_pull_id': {
'depends': ['manufacture_steps', 'manufacture_to_resupply'],
'create_values': {
diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py
index f3a9752446f..77bb41b8c7d 100644
--- a/addons/stock/models/stock_move.py
+++ b/addons/stock/models/stock_move.py
@@ -1453,11 +1453,6 @@ class StockMove(models.Model):
""" This method will try to apply the procure method MTO on some moves if
a compatible MTO route is found. Else the procure method will be set to MTS
"""
- try:
- mto_route = self.env['stock.warehouse']._find_global_route('stock.route_warehouse0_mto',
- 'Make To Order')
- except ValueError:
- mto_route = False
for move in self:
product_id = move.product_id
domain = [
@@ -1466,10 +1461,7 @@ class StockMove(models.Model):
('action', '!=', 'push')
]
rules = self.env['procurement.group']._search_rule(False, product_id, move.warehouse_id, domain)
- routes = product_id.route_ids + product_id.route_from_categ_ids + move.warehouse_id.route_ids
if rules and (rules.procure_method == 'make_to_order'):
move.procure_method = rules.procure_method
- elif mto_route and mto_route.id in [x.id for x in routes]:
- move.procure_method = 'make_to_order'
else:
move.procure_method = 'make_to_stock'