From 3cb337945628ffc243072c93a47f6fc55d0f03fd Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Thu, 3 Nov 2016 16:19:33 +0100 Subject: [PATCH] [FIX] point_of_sale -> stock: handling of lots/serial numbers Before, the quantities on the pack operations were set also for the pack operations that should have lots and had not, which is an inconsistency. As at the end of the PoS, errors are not shown and not rollbacked, this created really nasty situations. With this code, it was never meant to use lots in the PoS, but as the picking was not validated (but existed, because not rollbacked) some people thought it as a wanted feature. In the mean time, we had commit fafc048d028, but it will give problems as it will not automatically create a backorder. It is better not to do anything when lots are involved somewhere in the picking as then the user will see the open pickings in the PoS Orders picking type. It is also important to not do anything when it is a move without a picking. Needs to be forward ported to saas-11, where the file structure changed. opw: 692045 --- addons/point_of_sale/point_of_sale.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 50023d1d347..2d61f241fa2 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -957,9 +957,10 @@ class pos_order(osv.osv): picking_obj.force_assign(cr, uid, [picking_id], context=context) # Mark pack operations as done pick = picking_obj.browse(cr, uid, picking_id, context=context) - for pack in pick.pack_operation_ids.filtered(lambda pack: pack.product_id.tracking == 'none'): + for pack in pick.pack_operation_ids.filtered(lambda x: x.product_id.tracking == 'none'): self.pool['stock.pack.operation'].write(cr, uid, [pack.id], {'qty_done': pack.product_qty}, context=context) - picking_obj.action_done(cr, uid, [picking_id], context=context) + if not any([(x.product_id.tracking != 'none') for x in pick.pack_operation_ids]): + picking_obj.action_done(cr, uid, [picking_id], context=context) def create_picking(self, cr, uid, ids, context=None): """Create a picking for each order and validate it.""" @@ -1040,7 +1041,9 @@ class pos_order(osv.osv): if move_list and not return_picking_id and not order_picking_id: move_obj.action_confirm(cr, uid, move_list, context=context) move_obj.force_assign(cr, uid, move_list, context=context) - move_obj.action_done(cr, uid, move_list, context=context) + active_move_list = [x.id for x in move_obj.browse(cr, uid, move_list, context=context) if x.product_id.tracking == 'none'] + if active_move_list: + move_obj.action_done(cr, uid, active_move_list, context=context) return True