[FIX] stock: do not set deadline with fixed procurement group

- Set the Delivery in 2 steps in the warehouse
- Create a 'wave' route:
  - Sequence: 5
  - Apply on Product Categories
  - Rules:
    - Action: Pull From
    - Operation Type: San Francisco: Pick
    - Source Location: WH/Stock/Chairs
    - Destination Location: WH/Output
    - Supply Method: Take From Stock
    - Propagation of Procurement Group: Fixed
    - Fixed Procurement Group: Chairs
- Create a 'Chairs' product category, apply the wave route
- Create a 'Chair' product:
  - Category: Chairs
  - Storable
- Make some stock in WH/Stock/Chairs
- Create a SO for 1 Unit of Chair, confirm
  => a picking from WH/Stock/Chairs to WH/Output is created
- Create a SO for 2 Units of Chair, confirm
  => the 2 units are added to the previous picking

However, the 2 stock moves are not merged.

It happens because `date_deadline` prevents the grouping.

opw-2390630

closes odoo/odoo#62983

X-original-commit: c4505b704489db7ef47dd9a201def536a99d03f3
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-12-07 18:00:12 +00:00
parent e1c49246a2
commit 624079e283
2 changed files with 86 additions and 1 deletions
+1 -1
View File
@@ -301,7 +301,7 @@ class StockRule(models.Model):
'route_ids': [(4, route.id) for route in values.get('route_ids', [])],
'warehouse_id': self.propagate_warehouse_id.id or self.warehouse_id.id,
'date': date_scheduled,
'date_deadline': date_deadline,
'date_deadline': False if self.group_propagation_option == 'fixed' else date_deadline,
'propagate_cancel': self.propagate_cancel,
'description_picking': picking_description,
'priority': values.get('priority', "0"),
+85
View File
@@ -236,6 +236,91 @@ class TestProcRule(TransactionCase):
self.assertEqual(receipt_move2.date.date(), date.today())
self.assertEqual(receipt_move2.product_uom_qty, 10.0)
def test_fixed_procurement_01(self):
""" Run a procurement for 5 products when there are only 4 in stock then
check that MTO is applied on the moves when the rule is set to 'mts_else_mto'
"""
self.partner = self.env['res.partner'].create({'name': 'Partner'})
warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.user.id)], limit=1)
warehouse.delivery_steps = 'pick_ship'
final_location = self.partner.property_stock_customer
# Create a product and add 10 units in stock
product_a = self.env['product.product'].create({
'name': 'ProductA',
'type': 'product',
})
self.env['stock.quant']._update_available_quantity(product_a, warehouse.lot_stock_id, 10.0)
# Create a route which will allows 'wave picking'
wave_pg = self.env['procurement.group'].create({'name': 'Wave PG'})
wave_route = self.env['stock.location.route'].create({
'name': 'Wave for ProductA',
'product_selectable': True,
'sequence': 1,
'rule_ids': [(0, 0, {
'name': 'Stock -> output rule',
'action': 'pull',
'picking_type_id': self.ref('stock.picking_type_internal'),
'location_src_id': self.ref('stock.stock_location_stock'),
'location_id': self.ref('stock.stock_location_output'),
'group_propagation_option': 'fixed',
'group_id': wave_pg.id,
})],
})
# Set this route on `product_a`
product_a.write({
'route_ids': [(4, wave_route.id)]
})
# Create a procurement for 2 units
pg = self.env['procurement.group'].create({'name': 'Wave 1'})
self.env['procurement.group'].run([
pg.Procurement(
product_a,
2.0,
product_a.uom_id,
final_location,
'wave_part_1',
'wave_part_1',
warehouse.company_id,
{
'warehouse_id': warehouse,
'group_id': pg
}
)
])
# 2 pickings should be created: 1 for pick, 1 for ship
picking_pick = self.env['stock.picking'].search([('group_id', '=', wave_pg.id)])
picking_ship = self.env['stock.picking'].search([('group_id', '=', pg.id)])
self.assertAlmostEqual(picking_pick.move_lines.product_uom_qty, 2.0)
self.assertAlmostEqual(picking_ship.move_lines.product_uom_qty, 2.0)
# Create a procurement for 3 units
pg = self.env['procurement.group'].create({'name': 'Wave 2'})
self.env['procurement.group'].run([
pg.Procurement(
product_a,
3.0,
product_a.uom_id,
final_location,
'wave_part_2',
'wave_part_2',
warehouse.company_id,
{
'warehouse_id': warehouse,
'group_id': pg
}
)
])
# The picking for the pick operation should be reused and the lines merged.
picking_ship = self.env['stock.picking'].search([('group_id', '=', pg.id)])
self.assertAlmostEqual(picking_pick.move_lines.product_uom_qty, 5.0)
self.assertAlmostEqual(picking_ship.move_lines.product_uom_qty, 3.0)
class TestProcRuleLoad(TransactionCase):
def setUp(cls):