[FIX] stock: No backorder for tracked products
In Settings>Inventory>Operations enable "Batch Transfers" Create a [NonTrackedProd] product: - Product Type: Storable Product - Tracking: No tracking Create a [TrackedProd] product: - Product Type: Storable Product - Tracking: By Lots Make two POs with: - Prod [NonTrackedProd] qty 1 - Prod [TrackedProd] qty 1 Open Barcode Scanning app Select "Batch Transfers" Create a new batch with the incoming transfers from the POs Set only the [NonTrackedProd] lines as done and validate Issue: Error will block validation "You need to supply a Lot/Serial number for products" The system should let the user validate the operation and create a backorder instead of blocking the user opw-3777701 closes odoo/odoo#158330 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
This commit is contained in:
@@ -1058,7 +1058,7 @@ class Picking(models.Model):
|
||||
|
||||
def get_line_with_done_qty_ids(move_lines):
|
||||
# Get only move_lines that has some quantity set.
|
||||
return move_lines.filtered(lambda ml: ml.product_id and ml.product_id.tracking != 'none' and float_compare(ml.quantity, 0, precision_rounding=ml.product_uom_id.rounding)).ids
|
||||
return move_lines.filtered(lambda ml: ml.product_id and ml.product_id.tracking != 'none' and ml.picked and float_compare(ml.quantity, 0, precision_rounding=ml.product_uom_id.rounding)).ids
|
||||
|
||||
if separate_pickings:
|
||||
# If pickings are checked independently, get full/partial move_lines depending if each picking has no quantity set.
|
||||
|
||||
@@ -2542,6 +2542,40 @@ class TestStockFlow(TestStockCommon):
|
||||
backorder.button_validate()
|
||||
self.assertEqual(backorder.state, 'done')
|
||||
|
||||
def test_picking_mixed_tracking_with_backorder(self):
|
||||
self.productB.tracking = 'lot'
|
||||
picking = self.env['stock.picking'].create({
|
||||
'location_id': self.supplier_location,
|
||||
'location_dest_id': self.stock_location,
|
||||
'picking_type_id': self.picking_type_in,
|
||||
'company_id': self.env.company.id,
|
||||
})
|
||||
no_tracking_move = self.env['stock.move'].create({
|
||||
'name': self.productA.name,
|
||||
'product_id': self.productA.id,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': self.productA.uom_id.id,
|
||||
'picking_id': picking.id,
|
||||
'location_id': self.supplier_location,
|
||||
'location_dest_id': self.stock_location,
|
||||
})
|
||||
self.env['stock.move'].create({
|
||||
'name': self.productB.name,
|
||||
'product_id': self.productB.id,
|
||||
'product_uom_qty': 1,
|
||||
'product_uom': self.productB.uom_id.id,
|
||||
'picking_id': picking.id,
|
||||
'location_id': self.supplier_location,
|
||||
'location_dest_id': self.stock_location,
|
||||
})
|
||||
picking.action_confirm()
|
||||
|
||||
no_tracking_move.picked = True
|
||||
action_dict = picking.button_validate()
|
||||
backorder_wizard = Form(self.env['stock.backorder.confirmation'].with_context(action_dict['context'])).save()
|
||||
backorder_wizard.process()
|
||||
bo = self.env['stock.picking'].search([('backorder_id', '=', picking.id)])
|
||||
self.assertEqual(bo.state, 'assigned')
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestStockFlowPostInstall(TestStockCommon):
|
||||
|
||||
Reference in New Issue
Block a user