diff --git a/stock_mts_mto_rule/__manifest__.py b/stock_mts_mto_rule/__manifest__.py
index 833093068..661ee8950 100644
--- a/stock_mts_mto_rule/__manifest__.py
+++ b/stock_mts_mto_rule/__manifest__.py
@@ -1,22 +1,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
- 'name': 'Stock MTS+MTO Rule',
- 'summary': 'Add a MTS+MTO route',
- 'version': '12.0.1.0.1',
- 'development_status': 'Mature',
- 'category': 'Warehouse',
- 'website': 'https://github.com/OCA/stock-logistics-warehouse',
- 'author': 'Akretion,Odoo Community Association (OCA)',
- 'license': 'AGPL-3',
- 'application': False,
- 'installable': True,
- 'depends': [
- 'stock',
- ],
- 'data': [
- 'data/stock_data.xml',
- 'view/pull_rule.xml',
- 'view/warehouse.xml',
- ],
+ "name": "Stock MTS+MTO Rule",
+ "summary": "Add a MTS+MTO route",
+ "version": "12.0.1.0.1",
+ "development_status": "Mature",
+ "category": "Warehouse",
+ "website": "https://github.com/OCA/stock-logistics-warehouse",
+ "author": "Akretion,Odoo Community Association (OCA)",
+ "license": "AGPL-3",
+ "application": False,
+ "installable": True,
+ "depends": ["stock",],
+ "data": ["data/stock_data.xml", "view/pull_rule.xml", "view/warehouse.xml",],
}
diff --git a/stock_mts_mto_rule/data/stock_data.xml b/stock_mts_mto_rule/data/stock_data.xml
index 7b7dfb257..28fb7eac3 100644
--- a/stock_mts_mto_rule/data/stock_data.xml
+++ b/stock_mts_mto_rule/data/stock_data.xml
@@ -1,14 +1,11 @@
-
+
-
-
Make To Order + Make To Stock
5
-
+
-
diff --git a/stock_mts_mto_rule/models/stock_rule.py b/stock_mts_mto_rule/models/stock_rule.py
index eea219dcc..6d86fcc05 100644
--- a/stock_mts_mto_rule/models/stock_rule.py
+++ b/stock_mts_mto_rule/models/stock_rule.py
@@ -1,75 +1,83 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import api, fields, models, _
+from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools import float_compare, float_is_zero
class StockRule(models.Model):
- _inherit = 'stock.rule'
+ _inherit = "stock.rule"
action = fields.Selection(
- selection_add=[('split_procurement', 'Choose between MTS and MTO')])
- mts_rule_id = fields.Many2one(
- 'stock.rule', string="MTS Rule")
- mto_rule_id = fields.Many2one(
- 'stock.rule', string="MTO Rule")
+ selection_add=[("split_procurement", "Choose between MTS and MTO")]
+ )
+ mts_rule_id = fields.Many2one("stock.rule", string="MTS Rule")
+ mto_rule_id = fields.Many2one("stock.rule", string="MTO Rule")
- @api.constrains('action', 'mts_rule_id', 'mto_rule_id')
+ @api.constrains("action", "mts_rule_id", "mto_rule_id")
def _check_mts_mto_rule(self):
for rule in self:
- if rule.action == 'split_procurement':
+ if rule.action == "split_procurement":
if not rule.mts_rule_id or not rule.mto_rule_id:
- msg = _('No MTS or MTO rule configured on procurement '
- 'rule: %s!') % (rule.name, )
+ msg = _(
+ "No MTS or MTO rule configured on procurement " "rule: %s!"
+ ) % (rule.name,)
raise ValidationError(msg)
- if (rule.mts_rule_id.location_src_id.id !=
- rule.mto_rule_id.location_src_id.id):
- msg = _('Inconsistency between the source locations of '
- 'the mts and mto rules linked to the procurement '
- 'rule: %s! It should be the same.') % (rule.name,)
+ if (
+ rule.mts_rule_id.location_src_id.id
+ != rule.mto_rule_id.location_src_id.id
+ ):
+ msg = _(
+ "Inconsistency between the source locations of "
+ "the mts and mto rules linked to the procurement "
+ "rule: %s! It should be the same."
+ ) % (rule.name,)
raise ValidationError(msg)
@api.multi
def get_mto_qty_to_order(self, product, product_qty, product_uom, values):
self.ensure_one()
- precision = self.env['decimal.precision']\
- .precision_get('Product Unit of Measure')
+ precision = self.env["decimal.precision"].precision_get(
+ "Product Unit of Measure"
+ )
src_location_id = self.mts_rule_id.location_src_id.id
product_location = product.with_context(location=src_location_id)
virtual_available = product_location.virtual_available
- qty_available = product.uom_id._compute_quantity(
- virtual_available, product_uom)
+ qty_available = product.uom_id._compute_quantity(virtual_available, product_uom)
if float_compare(qty_available, 0.0, precision_digits=precision) > 0:
- if float_compare(qty_available, product_qty,
- precision_digits=precision) >= 0:
+ if (
+ float_compare(qty_available, product_qty, precision_digits=precision)
+ >= 0
+ ):
return 0.0
else:
return product_qty - qty_available
return product_qty
- def _run_split_procurement(self, product_id, product_qty, product_uom,
- location_id, name, origin, values):
- precision = self.env['decimal.precision']\
- .precision_get('Product Unit of Measure')
- needed_qty = self.get_mto_qty_to_order(product_id, product_qty,
- product_uom, values)
+ def _run_split_procurement(
+ self, product_id, product_qty, product_uom, location_id, name, origin, values
+ ):
+ precision = self.env["decimal.precision"].precision_get(
+ "Product Unit of Measure"
+ )
+ needed_qty = self.get_mto_qty_to_order(
+ product_id, product_qty, product_uom, values
+ )
if float_is_zero(needed_qty, precision_digits=precision):
- getattr(self.mts_rule_id, '_run_%s' % self.mts_rule_id.action)(
- product_id, product_qty, product_uom, location_id, name,
- origin, values)
- elif float_compare(needed_qty, product_qty,
- precision_digits=precision) == 0.0:
- getattr(self.mto_rule_id, '_run_%s' % self.mto_rule_id.action)(
- product_id, product_qty, product_uom, location_id, name,
- origin, values)
+ getattr(self.mts_rule_id, "_run_%s" % self.mts_rule_id.action)(
+ product_id, product_qty, product_uom, location_id, name, origin, values
+ )
+ elif float_compare(needed_qty, product_qty, precision_digits=precision) == 0.0:
+ getattr(self.mto_rule_id, "_run_%s" % self.mto_rule_id.action)(
+ product_id, product_qty, product_uom, location_id, name, origin, values
+ )
else:
mts_qty = product_qty - needed_qty
- getattr(self.mts_rule_id, '_run_%s' % self.mts_rule_id.action)(
- product_id, mts_qty, product_uom, location_id, name, origin,
- values)
- getattr(self.mto_rule_id, '_run_%s' % self.mto_rule_id.action)(
- product_id, needed_qty, product_uom, location_id, name,
- origin, values)
+ getattr(self.mts_rule_id, "_run_%s" % self.mts_rule_id.action)(
+ product_id, mts_qty, product_uom, location_id, name, origin, values
+ )
+ getattr(self.mto_rule_id, "_run_%s" % self.mto_rule_id.action)(
+ product_id, needed_qty, product_uom, location_id, name, origin, values
+ )
return True
diff --git a/stock_mts_mto_rule/models/stock_warehouse.py b/stock_mts_mto_rule/models/stock_warehouse.py
index ed8377bc9..5b7bc40f5 100644
--- a/stock_mts_mto_rule/models/stock_warehouse.py
+++ b/stock_mts_mto_rule/models/stock_warehouse.py
@@ -1,39 +1,41 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-from odoo import fields, models, _
+from odoo import _, fields, models
class StockWarehouse(models.Model):
- _inherit = 'stock.warehouse'
+ _inherit = "stock.warehouse"
mto_mts_management = fields.Boolean(
- 'Use MTO+MTS rules',
- help='If this new route is selected on product form view, a '
- 'purchase order will be created only if the virtual stock is '
- 'less than 0 else, the product will be taken from stocks')
- mts_mto_rule_id = fields.Many2one('stock.rule',
- 'MTO+MTS rule')
+ "Use MTO+MTS rules",
+ help="If this new route is selected on product form view, a "
+ "purchase order will be created only if the virtual stock is "
+ "less than 0 else, the product will be taken from stocks",
+ )
+ mts_mto_rule_id = fields.Many2one("stock.rule", "MTO+MTS rule")
def _get_all_routes(self):
routes = super(StockWarehouse, self)._get_all_routes()
- routes |= self.mapped('mts_mto_rule_id.route_id')
+ routes |= self.mapped("mts_mto_rule_id.route_id")
return routes
def _update_name_and_code(self, new_name=False, new_code=False):
- res = super(StockWarehouse, self)._update_name_and_code(new_name,
- new_code)
+ res = super(StockWarehouse, self)._update_name_and_code(new_name, new_code)
if not new_name:
return res
- for warehouse in self.filtered('mts_mto_rule_id'):
- warehouse.mts_mto_rule_id.write({
- 'name': warehouse.mts_mto_rule_id.name.replace(warehouse.name,
- new_name, 1),
- })
+ for warehouse in self.filtered("mts_mto_rule_id"):
+ warehouse.mts_mto_rule_id.write(
+ {
+ "name": warehouse.mts_mto_rule_id.name.replace(
+ warehouse.name, new_name, 1
+ ),
+ }
+ )
return res
def _get_route_name(self, route_type):
- if route_type == 'mts_mto':
- return _('MTS+MTO')
+ if route_type == "mts_mto":
+ return _("MTS+MTO")
return super(StockWarehouse, self)._get_route_name(route_type)
def _get_global_route_rules_values(self):
@@ -43,51 +45,60 @@ class StockWarehouse(models.Model):
location_dest_id = rule.dest_loc
picking_type_id = rule.picking_type
res = super(StockWarehouse, self)._get_global_route_rules_values()
- res.update({
- 'mts_mto_rule_id': {
- 'depends': ['delivery_steps', 'mto_mts_management'],
- 'create_values': {
- 'action': 'pull',
- 'procure_method': 'make_to_order',
- 'company_id': self.company_id.id,
- 'auto': 'manual',
- 'propagate': True,
- 'route_id': self._find_global_route(
- 'stock_mts_mto_rule.route_mto_mts',
- _('Make To Order + Make To Stock')).id,
+ res.update(
+ {
+ "mts_mto_rule_id": {
+ "depends": ["delivery_steps", "mto_mts_management"],
+ "create_values": {
+ "action": "pull",
+ "procure_method": "make_to_order",
+ "company_id": self.company_id.id,
+ "auto": "manual",
+ "propagate": True,
+ "route_id": self._find_global_route(
+ "stock_mts_mto_rule.route_mto_mts",
+ _("Make To Order + Make To Stock"),
+ ).id,
+ },
+ "update_values": {
+ "active": self.mto_mts_management,
+ "name": self._format_rulename(
+ location_id, location_dest_id, "MTS+MTO"
+ ),
+ "location_id": location_dest_id.id,
+ "location_src_id": location_id.id,
+ "picking_type_id": picking_type_id.id,
+ },
},
- 'update_values': {
- 'active': self.mto_mts_management,
- 'name': self._format_rulename(location_id,
- location_dest_id,
- 'MTS+MTO'),
- 'location_id': location_dest_id.id,
- 'location_src_id': location_id.id,
- 'picking_type_id': picking_type_id.id,
- }
- },
- })
+ }
+ )
return res
def _create_or_update_global_routes_rules(self):
- res = super(StockWarehouse, self)\
- ._create_or_update_global_routes_rules()
+ res = super(StockWarehouse, self)._create_or_update_global_routes_rules()
- if (self.mto_mts_management and self.mts_mto_rule_id
- and self.mts_mto_rule_id.action != 'split_procurement'):
+ if (
+ self.mto_mts_management
+ and self.mts_mto_rule_id
+ and self.mts_mto_rule_id.action != "split_procurement"
+ ):
# Cannot create or update with the 'split_procurement' action due
# to constraint and the fact that the constrained rule_ids may
# not exist during the initial (or really any) calls of
# _get_global_route_rules_values
- rule = self.env['stock.rule'].search([
- ('location_id', '=', self.mts_mto_rule_id.location_id.id),
- ('location_src_id', '=',
- self.mts_mto_rule_id.location_src_id.id),
- ('route_id', '=', self.delivery_route_id.id),
- ], limit=1)
- self.mts_mto_rule_id.write({
- 'action': 'split_procurement',
- 'mts_rule_id': rule.id,
- 'mto_rule_id': self.mto_pull_id.id,
- })
+ rule = self.env["stock.rule"].search(
+ [
+ ("location_id", "=", self.mts_mto_rule_id.location_id.id),
+ ("location_src_id", "=", self.mts_mto_rule_id.location_src_id.id),
+ ("route_id", "=", self.delivery_route_id.id),
+ ],
+ limit=1,
+ )
+ self.mts_mto_rule_id.write(
+ {
+ "action": "split_procurement",
+ "mts_rule_id": rule.id,
+ "mto_rule_id": self.mto_pull_id.id,
+ }
+ )
return res
diff --git a/stock_mts_mto_rule/tests/test_mto_mts_route.py b/stock_mts_mto_rule/tests/test_mto_mts_route.py
index f40e2433d..13ae60a11 100644
--- a/stock_mts_mto_rule/tests/test_mto_mts_route.py
+++ b/stock_mts_mto_rule/tests/test_mto_mts_route.py
@@ -5,101 +5,146 @@ from odoo.tests.common import TransactionCase
class TestMtoMtsRoute(TransactionCase):
-
def _create_quant(self, qty):
- self.quant = self.env['stock.quant'].create({
- 'owner_id': self.company_partner.id,
- 'location_id': self.env.ref('stock.stock_location_stock').id,
- 'product_id': self.product.id,
- 'quantity': qty,
- })
+ self.quant = self.env["stock.quant"].create(
+ {
+ "owner_id": self.company_partner.id,
+ "location_id": self.env.ref("stock.stock_location_stock").id,
+ "product_id": self.product.id,
+ "quantity": qty,
+ }
+ )
def test_standard_mto_route(self):
- mto_route = self.env.ref('stock.route_warehouse0_mto')
+ mto_route = self.env.ref("stock.route_warehouse0_mto")
self.product.route_ids = [(6, 0, [mto_route.id])]
- self.group.run(self.product, 2.0, self.uom, self.customer_loc,
- self.product.name, 'test', self.procurement_vals)
- moves = self.move_obj.search([('group_id', '=', self.group.id)])
+ self.group.run(
+ self.product,
+ 2.0,
+ self.uom,
+ self.customer_loc,
+ self.product.name,
+ "test",
+ self.procurement_vals,
+ )
+ moves = self.move_obj.search([("group_id", "=", self.group.id)])
self.assertEqual(len(moves), 2)
def test_standard_mts_route(self):
- self.group.run(self.product, 2.0, self.uom, self.customer_loc,
- self.product.name, 'test', self.procurement_vals)
- moves = self.move_obj.search([('group_id', '=', self.group.id)])
+ self.group.run(
+ self.product,
+ 2.0,
+ self.uom,
+ self.customer_loc,
+ self.product.name,
+ "test",
+ self.procurement_vals,
+ )
+ moves = self.move_obj.search([("group_id", "=", self.group.id)])
self.assertEqual(len(moves), 1)
def test_mts_mto_route_split(self):
- mto_mts_route = self.env.ref('stock_mts_mto_rule.route_mto_mts')
+ mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
self._create_quant(1.0)
- self.group.run(self.product, 2.0, self.uom, self.customer_loc,
- self.product.name, 'test', self.procurement_vals)
- moves = self.env['stock.move'].search(
- [('group_id', '=', self.group.id)])
+ self.group.run(
+ self.product,
+ 2.0,
+ self.uom,
+ self.customer_loc,
+ self.product.name,
+ "test",
+ self.procurement_vals,
+ )
+ moves = self.env["stock.move"].search([("group_id", "=", self.group.id)])
self.assertEqual(3, len(moves))
- move_mts = self.env['stock.move'].search(
- [('group_id', '=', self.group.id),
- ('location_dest_id', '=', self.customer_loc.id),
- ('procure_method', '=', 'make_to_stock')])
+ move_mts = self.env["stock.move"].search(
+ [
+ ("group_id", "=", self.group.id),
+ ("location_dest_id", "=", self.customer_loc.id),
+ ("procure_method", "=", "make_to_stock"),
+ ]
+ )
self.assertEqual(1, len(move_mts))
self.assertEqual(1.0, move_mts.product_uom_qty)
- self.assertEqual('confirmed', move_mts.state)
- move_mto = self.env['stock.move'].search(
- [('group_id', '=', self.group.id),
- ('location_dest_id', '=', self.customer_loc.id),
- ('procure_method', '=', 'make_to_order')])
+ self.assertEqual("confirmed", move_mts.state)
+ move_mto = self.env["stock.move"].search(
+ [
+ ("group_id", "=", self.group.id),
+ ("location_dest_id", "=", self.customer_loc.id),
+ ("procure_method", "=", "make_to_order"),
+ ]
+ )
self.assertEqual(1, len(move_mto))
- self.assertEqual('waiting', move_mto.state)
+ self.assertEqual("waiting", move_mto.state)
def test_mts_mto_route_mto_only(self):
- mto_mts_route = self.env.ref('stock_mts_mto_rule.route_mto_mts')
+ mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
- self.group.run(self.product, 2.0, self.uom, self.customer_loc,
- self.product.name, 'test', self.procurement_vals)
- moves = self.env['stock.move'].search(
- [('group_id', '=', self.group.id),
- ('location_dest_id', '=', self.customer_loc.id)])
+ self.group.run(
+ self.product,
+ 2.0,
+ self.uom,
+ self.customer_loc,
+ self.product.name,
+ "test",
+ self.procurement_vals,
+ )
+ moves = self.env["stock.move"].search(
+ [
+ ("group_id", "=", self.group.id),
+ ("location_dest_id", "=", self.customer_loc.id),
+ ]
+ )
self.assertEqual(1, len(moves))
self.assertEqual(2.0, moves[0].product_uom_qty)
- self.assertEqual('make_to_order',
- moves[0].procure_method)
+ self.assertEqual("make_to_order", moves[0].procure_method)
def test_mts_mto_route_mts_only(self):
- mto_mts_route = self.env.ref('stock_mts_mto_rule.route_mto_mts')
+ mto_mts_route = self.env.ref("stock_mts_mto_rule.route_mto_mts")
self.product.route_ids = [(6, 0, [mto_mts_route.id])]
self._create_quant(3.0)
- self.group.run(self.product, 2.0, self.uom, self.customer_loc,
- self.product.name, 'test', self.procurement_vals)
- moves = self.env['stock.move'].search(
- [('group_id', '=', self.group.id)])
+ self.group.run(
+ self.product,
+ 2.0,
+ self.uom,
+ self.customer_loc,
+ self.product.name,
+ "test",
+ self.procurement_vals,
+ )
+ moves = self.env["stock.move"].search([("group_id", "=", self.group.id)])
self.assertEqual(1, len(moves))
self.assertEqual(2.0, moves[0].product_uom_qty)
- self.assertEqual('make_to_stock',
- moves[0].procure_method)
+ self.assertEqual("make_to_stock", moves[0].procure_method)
def test_mts_mto_rule_contrains(self):
- rule = self.env['stock.rule'].search(
- [('action', '=', 'split_procurement')], limit=1)
+ rule = self.env["stock.rule"].search(
+ [("action", "=", "split_procurement")], limit=1
+ )
with self.assertRaises(exceptions.ValidationError):
- rule.write({'mts_rule_id': False})
+ rule.write({"mts_rule_id": False})
with self.assertRaises(exceptions.ValidationError):
- rule.write({'mts_rule_id': self.dummy_rule.id})
+ rule.write({"mts_rule_id": self.dummy_rule.id})
def test_mts_mto_route_mto_removed(self):
- self.env.ref('stock_mts_mto_rule.route_mto_mts').unlink()
+ self.env.ref("stock_mts_mto_rule.route_mto_mts").unlink()
with self.assertRaises(exceptions.UserError):
# mts_mto_rule_id is checked as a global rule
self.warehouse.mts_mto_rule_id = False
def test_mts_mto_route_mts_removed(self):
self.warehouse.mto_mts_management = True
- rules = self.env['stock.rule'].search([
- ('location_src_id', '=', self.warehouse.lot_stock_id.id),
- ('route_id', '=', self.warehouse.delivery_route_id.id),
- ])
+ rules = self.env["stock.rule"].search(
+ [
+ ("location_src_id", "=", self.warehouse.lot_stock_id.id),
+ ("route_id", "=", self.warehouse.delivery_route_id.id),
+ ]
+ )
self.env.cr.execute(
- 'UPDATE stock_move SET rule_id = NULL WHERE rule_id IN %s',
- (tuple(rules.ids), ))
+ "UPDATE stock_move SET rule_id = NULL WHERE rule_id IN %s",
+ (tuple(rules.ids),),
+ )
self.warehouse.mts_mto_rule_id = False
self.warehouse.mto_mts_management = True
self.assertTrue(self.warehouse.mts_mto_rule_id)
@@ -115,13 +160,14 @@ class TestMtoMtsRoute(TransactionCase):
mts_mto_route = self.warehouse.mts_mto_rule_id
self.assertEqual(mts_mto_route.warehouse_id, self.warehouse)
self.assertEqual(
- mts_mto_route.location_id, self.warehouse.mto_pull_id.location_id)
+ mts_mto_route.location_id, self.warehouse.mto_pull_id.location_id
+ )
self.assertEqual(
- mts_mto_route.picking_type_id,
- self.warehouse.mto_pull_id.picking_type_id)
+ mts_mto_route.picking_type_id, self.warehouse.mto_pull_id.picking_type_id
+ )
self.assertEqual(
- mts_mto_route.route_id,
- self.env.ref('stock_mts_mto_rule.route_mto_mts'))
+ mts_mto_route.route_id, self.env.ref("stock_mts_mto_rule.route_mto_mts")
+ )
def test_remove_mts_mto_management(self):
warehouse_rule = self.warehouse.mts_mto_rule_id
@@ -136,47 +182,40 @@ class TestMtoMtsRoute(TransactionCase):
def test_rename_warehouse(self):
rule_name = self.warehouse.mts_mto_rule_id.name
- new_warehouse_name = 'NewName'
- new_rule_name = rule_name.replace(
- self.warehouse.name, new_warehouse_name, 1)
+ new_warehouse_name = "NewName"
+ new_rule_name = rule_name.replace(self.warehouse.name, new_warehouse_name, 1)
self.warehouse.name = new_warehouse_name
self.assertEqual(new_rule_name, self.warehouse.mts_mto_rule_id.name)
def setUp(self):
super(TestMtoMtsRoute, self).setUp()
- self.move_obj = self.env['stock.move']
- self.warehouse = self.env.ref('stock.warehouse0')
- self.uom = self.env['uom.uom'].browse(1)
+ self.move_obj = self.env["stock.move"]
+ self.warehouse = self.env.ref("stock.warehouse0")
+ self.uom = self.env["uom.uom"].browse(1)
self.warehouse.mto_mts_management = True
- self.customer_loc = self.env.ref('stock.stock_location_customers')
- self.product = self.env['product.product'].create({
- 'name': 'Test product',
- 'type': 'product',
- })
- self.company_partner = self.env.ref('base.main_partner')
- self.group = self.env['procurement.group'].create({
- 'name': 'test',
- })
- self.procurement_vals = {
- 'warehouse_id': self.warehouse, 'group_id': self.group
- }
+ self.customer_loc = self.env.ref("stock.stock_location_customers")
+ self.product = self.env["product.product"].create(
+ {"name": "Test product", "type": "product",}
+ )
+ self.company_partner = self.env.ref("base.main_partner")
+ self.group = self.env["procurement.group"].create({"name": "test",})
+ self.procurement_vals = {"warehouse_id": self.warehouse, "group_id": self.group}
# Since mrp and purchase modules may not be installed, we need to
# create a dummy step to show that mts, mto, and mts+mto flows work.
# Else, if purchase/manufacture are not installed, the mto would fail.
route_vals = {
- 'warehouse_selectable': True,
- 'name': 'dummy route',
+ "warehouse_selectable": True,
+ "name": "dummy route",
}
- self.dummy_route = self.env['stock.location.route'].create(route_vals)
+ self.dummy_route = self.env["stock.location.route"].create(route_vals)
rule_vals = {
- 'location_id': self.env.ref('stock.stock_location_stock').id,
- 'location_src_id': self.env.ref(
- 'stock.stock_location_suppliers').id,
- 'action': 'pull',
- 'warehouse_id': self.warehouse.id,
- 'picking_type_id': self.env.ref('stock.picking_type_out').id,
- 'name': 'dummy rule',
- 'route_id': self.dummy_route.id,
+ "location_id": self.env.ref("stock.stock_location_stock").id,
+ "location_src_id": self.env.ref("stock.stock_location_suppliers").id,
+ "action": "pull",
+ "warehouse_id": self.warehouse.id,
+ "picking_type_id": self.env.ref("stock.picking_type_out").id,
+ "name": "dummy rule",
+ "route_id": self.dummy_route.id,
}
- self.dummy_rule = self.env['stock.rule'].create(rule_vals)
- self.warehouse.write({'route_ids': [(4, self.dummy_route.id)]})
+ self.dummy_rule = self.env["stock.rule"].create(rule_vals)
+ self.warehouse.write({"route_ids": [(4, self.dummy_route.id)]})
diff --git a/stock_mts_mto_rule/view/pull_rule.xml b/stock_mts_mto_rule/view/pull_rule.xml
index a3e5843e4..3117d7ba7 100644
--- a/stock_mts_mto_rule/view/pull_rule.xml
+++ b/stock_mts_mto_rule/view/pull_rule.xml
@@ -1,36 +1,41 @@
-
+
-
stock.location.route.form.mts.mto
stock.location.route
-
-
+
+ attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
+ />
-
stock.rule.form.mts.mto
stock.rule
-
-
+
+ attrs="{'invisible': [('action', '!=', 'split_procurement')]}"
+ />
-
diff --git a/stock_mts_mto_rule/view/warehouse.xml b/stock_mts_mto_rule/view/warehouse.xml
index a0368b30c..0abc6e5d8 100644
--- a/stock_mts_mto_rule/view/warehouse.xml
+++ b/stock_mts_mto_rule/view/warehouse.xml
@@ -1,15 +1,13 @@
-
+
-
view_warehouse_inherited
stock.warehouse
-
+
-