Skip to content

Commit

Permalink
[FIX] delivery, stock: no propagation of carrier on MTO products
Browse files Browse the repository at this point in the history
Usecase to reproduce:
- Create a product with replenish on order route
- Create a SO for this product and add a shipping method
- Confirm the SO

The shipping method is not on the product.

It's due to the MTO delivery rule that miss the propagation of carrier
option. It's not set by default while it's is on the classic delivery
rule on the warehouse.

To avoid confusion we add it by default on both rules

opw-3112455
opw-3113180

closes odoo#108818

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
  • Loading branch information
amoyaux committed Jan 6, 2023
1 parent 5312706 commit c02df95
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 25 deletions.
59 changes: 34 additions & 25 deletions addons/delivery/tests/test_carrier_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ def setUpClass(cls):
'name': 'Super Product',
'invoice_policy': 'delivery',
})
mto_route = cls.env.ref('stock.route_warehouse0_mto')
mto_route.active = True
cls.warehouse.mto_pull_id.procure_method = "make_to_stock"
cls.mto_product = cls.ProductProduct.create({
'name': 'MTO Product',
'invoice_policy': 'delivery',
'route_ids': [(6, 0, mto_route.ids)],
})
cls.rule_pack = cls.env["procurement.group"]._get_rule(
cls.super_product, cls.output_location, {"warehouse_id": cls.warehouse})

Expand Down Expand Up @@ -88,29 +96,30 @@ def test_carrier_propagation(self):
"""
self.rule_pack.propagate_carrier = True

so = self.SaleOrder.create({
'name': 'Sale order',
'partner_id': self.partner_propagation.id,
'partner_invoice_id': self.partner_propagation.id,
'order_line': [
(0, 0, {'name': self.super_product.name, 'product_id': self.super_product.id, 'product_uom_qty': 1, 'price_unit': 1,}),
]
})
delivery_wizard = Form(self.env['choose.delivery.carrier'].with_context({
'default_order_id': so.id,
'default_carrier_id': self.normal_delivery.id,
}))
choose_delivery_carrier = delivery_wizard.save()
choose_delivery_carrier.button_confirm()
# Confirm the SO
so.action_confirm()
move_out = self.StockMove.search([("location_dest_id.usage", "=", "customer"), ("product_id", "=", self.super_product.id)])
self.assertEqual(
self.normal_delivery,
move_out.picking_id.carrier_id,
)
move_pack = self.StockMove.search([("move_dest_ids", "in", move_out.ids)])
self.assertEqual(
self.normal_delivery,
move_pack.picking_id.carrier_id,
for product in [self.super_product, self.mto_product]:
so = self.SaleOrder.create({
'name': 'Sale order',
'partner_id': self.partner_propagation.id,
'partner_invoice_id': self.partner_propagation.id,
'order_line': [
(0, 0, {'name': product.name, 'product_id': product.id, 'product_uom_qty': 1, 'price_unit': 1,}),
]
})
delivery_wizard = Form(self.env['choose.delivery.carrier'].with_context({
'default_order_id': so.id,
'default_carrier_id': self.normal_delivery.id,
}))
choose_delivery_carrier = delivery_wizard.save()
choose_delivery_carrier.button_confirm()
# Confirm the SO
so.action_confirm()
move_out = self.StockMove.search([("location_dest_id.usage", "=", "customer"), ("product_id", "=", product.id)])
self.assertEqual(
self.normal_delivery,
move_out.picking_id.carrier_id,
)
move_pack = self.StockMove.search([("move_dest_ids", "in", move_out.ids)])
self.assertEqual(
self.normal_delivery,
move_pack.picking_id.carrier_id,
)
1 change: 1 addition & 0 deletions addons/stock/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def _get_global_route_rules_values(self):
'company_id': self.company_id.id,
'action': 'pull',
'auto': 'manual',
'propagate_carrier': True,
'route_id': self._find_global_route('stock.route_warehouse0_mto', _('Make To Order')).id
},
'update_values': {
Expand Down

0 comments on commit c02df95

Please sign in to comment.