Skip to content

Commit 2b57964

Browse files
committed
[FIX] point_of_sale: assign lot_id on quants when applicable
Currently, when buying a product in pos and using a new lot id, the quantities do not reflect this lot id. Steps to reproduce: ------------------- * Create a product: * Storable * Available in POS * Tracked by lots * Open shop session * Select the product just created * Enter anything as the lot number * Finalize order * Close session * In the back-end, navigate to the product page * Select the smart button **On hand** > Observation: The lot is not reflected Why the fix: ------------ When the session in closed, `stock.lot` are created but not reflected on the inventory quantity updates. We can add the `lot_id` when creating move lines as where we mention it, it will always have a related existing lot as per: https://github.com/odoo/odoo/blob/ba21b59d1234d13b5d4460facd60c586648048b8/addons/point_of_sale/models/stock_picking.py#L290 opw-4359435 closes odoo#193450 Signed-off-by: David Monnom (moda) <[email protected]>
1 parent fec3783 commit 2b57964

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

addons/point_of_sale/models/stock_picking.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def _add_mls_related_to_order(self, related_order_lines, are_qties_done=True):
300300
else:
301301
ml_vals.update({
302302
'lot_name': existing_lot.name,
303+
'lot_id': existing_lot.id,
303304
})
304305
else:
305306
ml_vals.update({'lot_name': lot.lot_name})

addons/point_of_sale/tests/test_point_of_sale_flow.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,9 @@ def test_order_unexisting_lots(self):
22302230
})
22312231
order_payment.with_context(payment_context).check()
22322232
self.pos_config.current_session_id.action_pos_session_closing_control()
2233-
self.assertEqual(order.picking_ids.move_line_ids_without_package.lot_id.name, '1001')
2233+
order_lot_id = order.picking_ids.move_line_ids_without_package.lot_id
2234+
self.assertEqual(order_lot_id.name, '1001')
2235+
self.assertTrue(all([quant.lot_id == order_lot_id for quant in self.env['stock.quant'].search([('product_id', '=', self.product2.id)])]))
22342236

22352237
def test_product_combo_creation(self):
22362238
"""We check that combo products are created without taxes."""

0 commit comments

Comments
 (0)