diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index 9d3361100ac..40fa5c03f0e 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -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. diff --git a/addons/stock/tests/test_stock_flow.py b/addons/stock/tests/test_stock_flow.py index 954a6504c56..87458e953ef 100644 --- a/addons/stock/tests/test_stock_flow.py +++ b/addons/stock/tests/test_stock_flow.py @@ -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):