[IMP] stock: Hide Replenish on Order routes
Improve onboarding by removing the replenish on order route. Companies that do MTO process could unarchive the route in order to have a basic configuration. closes odoo/odoo#55147 Task: 2245882 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
@@ -15,9 +15,9 @@ class TestProcurement(TestMrpCommon):
|
||||
# Update BOM
|
||||
self.bom_3.bom_line_ids.filtered(lambda x: x.product_id == self.product_5).unlink()
|
||||
self.bom_1.bom_line_ids.filtered(lambda x: x.product_id == self.product_1).unlink()
|
||||
|
||||
# Update route
|
||||
self.warehouse = self.env.ref('stock.warehouse0')
|
||||
self.warehouse.mto_pull_id.route_id.active = True
|
||||
route_manufacture = self.warehouse.manufacture_pull_id.route_id.id
|
||||
route_mto = self.warehouse.mto_pull_id.route_id.id
|
||||
self.product_4.write({'route_ids': [(6, 0, [route_manufacture, route_mto])]})
|
||||
@@ -115,6 +115,7 @@ class TestProcurement(TestMrpCommon):
|
||||
# set the MTO route to the parent category (all)
|
||||
self.warehouse = self.env.ref('stock.warehouse0')
|
||||
mto_route = self.warehouse.mto_pull_id.route_id
|
||||
mto_route.active = True
|
||||
mto_route.product_categ_selectable = True
|
||||
all_categ_id.write({'route_ids': [(6, 0, [mto_route.id])]})
|
||||
|
||||
@@ -130,6 +131,7 @@ class TestProcurement(TestMrpCommon):
|
||||
def test_procurement_3(self):
|
||||
warehouse = self.env['stock.warehouse'].search([], limit=1)
|
||||
warehouse.write({'reception_steps': 'three_steps'})
|
||||
warehouse.mto_pull_id.route_id.active = True
|
||||
self.env['stock.location']._parent_store_compute()
|
||||
warehouse.reception_route_id.rule_ids.filtered(
|
||||
lambda p: p.location_src_id == warehouse.wh_input_stock_loc_id and
|
||||
@@ -303,7 +305,7 @@ class TestProcurement(TestMrpCommon):
|
||||
def test_production_delay_alert(self):
|
||||
"""Check if the delay alert is set to True on the stock move."""
|
||||
self.env['stock.rule'].search([]).delay_alert = True
|
||||
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
parent_product = self.env['product.template'].create({
|
||||
'name': 'Parent product',
|
||||
'route_ids': [
|
||||
|
||||
@@ -133,6 +133,7 @@ class TestMultistepManufacturingWarehouse(TestMrpCommon):
|
||||
warehouse.manufacture_steps = 'pbm_sam'
|
||||
warehouse.delivery_steps = 'pick_pack_ship'
|
||||
self.warehouse.flush()
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
self.env['stock.quant']._update_available_quantity(self.raw_product, self.warehouse.lot_stock_id, 4.0)
|
||||
picking_customer = self.env['stock.picking'].create({
|
||||
'location_id': self.warehouse.wh_output_stock_loc_id.id,
|
||||
|
||||
@@ -170,7 +170,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
|
||||
(self.comp1 + self.comp2).write({'route_ids': [(4, resupply_sub_on_order_route.id, None)]})
|
||||
|
||||
# Tick "manufacture" and MTO on self.comp2
|
||||
mto_route = self.env['stock.location.route'].search([('name', '=', 'Replenish on Order (MTO)')])
|
||||
mto_route = self.env.ref('stock.route_warehouse0_mto')
|
||||
mto_route.active = True
|
||||
manufacture_route = self.env['stock.location.route'].search([('name', '=', 'Manufacture')])
|
||||
self.comp2.write({'route_ids': [(4, manufacture_route.id, None)]})
|
||||
self.comp2.write({'route_ids': [(4, mto_route.id, None)]})
|
||||
@@ -228,7 +229,8 @@ class TestSubcontractingFlows(TestMrpSubcontractingCommon):
|
||||
the delivery and MO exist.
|
||||
"""
|
||||
# Tick "manufacture" and MTO on self.comp2
|
||||
mto_route = self.env['stock.location.route'].search([('name', '=', 'Replenish on Order (MTO)')])
|
||||
mto_route = self.env.ref('stock.route_warehouse0_mto')
|
||||
mto_route.active = True
|
||||
manufacture_route = self.env['stock.location.route'].search([('name', '=', 'Manufacture')])
|
||||
self.comp2.write({'route_ids': [(4, manufacture_route.id, None)]})
|
||||
self.comp2.write({'route_ids': [(4, mto_route.id, None)]})
|
||||
|
||||
@@ -16,6 +16,7 @@ class TestSubcontractingDropshippingFlows(TestMrpSubcontractingCommon):
|
||||
- Delivery for the component to the subcontractor for the specified wh.
|
||||
- Po created for the component.
|
||||
"""
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
mto_route = self.env['stock.location.route'].search([('name', '=', 'Replenish on Order (MTO)')])
|
||||
resupply_route = self.env['stock.location.route'].search([('name', '=', 'Resupply Subcontractor on Order')])
|
||||
buy_route = self.env['stock.location.route'].search([('name', '=', 'Buy')])
|
||||
|
||||
@@ -25,6 +25,7 @@ class PurchaseTestCommon(TestStockCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(PurchaseTestCommon, cls).setUpClass()
|
||||
cls.env.ref('stock.route_warehouse0_mto').active = True
|
||||
|
||||
cls.route_buy = cls.warehouse_1.buy_pull_id.route_id.id
|
||||
cls.route_mto = cls.warehouse_1.mto_pull_id.route_id.id
|
||||
|
||||
@@ -10,6 +10,7 @@ class TestMultistepManufacturing(TestMrpCommon):
|
||||
def setUp(self):
|
||||
super(TestMultistepManufacturing, self).setUp()
|
||||
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
self.MrpProduction = self.env['mrp.production']
|
||||
# Create warehouse
|
||||
warehouse_form = Form(self.env['stock.warehouse'])
|
||||
|
||||
@@ -14,6 +14,7 @@ class TestSaleMrpFlow(ValuationReconciliationTestCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls, chart_template_ref=None):
|
||||
super().setUpClass(chart_template_ref=chart_template_ref)
|
||||
cls.env.ref('stock.route_warehouse0_mto').active = True
|
||||
|
||||
# Useful models
|
||||
cls.StockMove = cls.env['stock.move']
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestSaleMrpLeadTime(TestStockCommon):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSaleMrpLeadTime, self).setUp()
|
||||
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
# Update the product_1 with type, route, Manufacturing Lead Time and Customer Lead Time
|
||||
with Form(self.product_1) as p1:
|
||||
p1.type = 'product'
|
||||
|
||||
@@ -10,6 +10,7 @@ from odoo.tools import mute_logger
|
||||
class TestSaleMrpProcurement(TransactionCase):
|
||||
|
||||
def test_sale_mrp(self):
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
warehouse0 = self.env.ref('stock.warehouse0')
|
||||
# In order to test the sale_mrp module in OpenERP, I start by creating a new product 'Slider Mobile'
|
||||
# I define product category Mobile Products Sellable.
|
||||
@@ -73,7 +74,7 @@ class TestSaleMrpProcurement(TransactionCase):
|
||||
to avoid generating multiple deliveries
|
||||
to the customer location
|
||||
"""
|
||||
|
||||
self.env.ref('stock.route_warehouse0_mto').active = True
|
||||
# Create warehouse
|
||||
self.customer_location = self.env['ir.model.data'].xmlid_to_res_id('stock.stock_location_customers')
|
||||
warehouse_form = Form(self.env['stock.warehouse'])
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
<record id="route_warehouse0_mto" model='stock.location.route'>
|
||||
<field name="name">Replenish on Order (MTO)</field>
|
||||
<field name="company_id"></field>
|
||||
<field name="active">False</field>
|
||||
<field name="sequence">5</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -602,6 +602,8 @@ class ProductTemplate(models.Model):
|
||||
# to influence computed field.
|
||||
location_id = fields.Many2one('stock.location', 'Location', store=False)
|
||||
warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', store=False)
|
||||
has_available_route_ids = fields.Boolean(
|
||||
'Routes can be selected on this product', compute='_compute_has_available_route_ids')
|
||||
route_ids = fields.Many2many(
|
||||
'stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes',
|
||||
domain=[('product_selectable', '=', True)],
|
||||
@@ -617,6 +619,10 @@ class ProductTemplate(models.Model):
|
||||
relation="stock.location.route", string="Category Routes",
|
||||
related='categ_id.total_route_ids', readonly=False)
|
||||
|
||||
@api.depends('type')
|
||||
def _compute_has_available_route_ids(self):
|
||||
self.has_available_route_ids = self.env['stock.location.route'].search_count([('product_selectable', '=', True)])
|
||||
|
||||
@api.depends(
|
||||
'product_variant_ids',
|
||||
'product_variant_ids.stock_move_ids.product_qty',
|
||||
|
||||
@@ -102,10 +102,11 @@
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='group_lots_and_weight']" position="before">
|
||||
<field name="has_available_route_ids" invisible="1"/>
|
||||
<group string="Operations" name="operations">
|
||||
<label for="route_ids" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
|
||||
<div>
|
||||
<field name="route_ids" class="mb-0" widget="many2many_checkboxes" attrs="{'invisible': [('type', 'in', ['service', 'digital'])]}"/>
|
||||
<field name="route_ids" class="mb-0" widget="many2many_checkboxes" attrs="{'invisible': ['|', ('has_available_route_ids', '=', False), ('type', 'in', ['service', 'digital'])]}"/>
|
||||
<button string="View Diagram" type="action" name="%(action_open_routes)d" icon="fa-arrow-right"
|
||||
attrs="{'invisible':[('type', 'not in', ['product', 'consu'])]}"
|
||||
class="btn btn-link pt-0" context="{'default_product_tmpl_id': id}"/>
|
||||
|
||||
Reference in New Issue
Block a user