From 372a3fade2378e06e8eb36dbe6a81945e5ab9486 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 3 Nov 2014 10:15:29 +0100 Subject: [PATCH] [FIX] Deletion of lines in picking front-end when a product qty is already 0, and minus is clicked --- addons/stock/stock.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index c3fc1f220d7..8a59171a4a8 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -3953,6 +3953,11 @@ class stock_pack_operation(osv.osv): weight is used for weighted products for which quantity != 1 (not per unit but e.g. per kg) returns True ''' + print "Search and increment " + str(weight) + if increment: + print "INCREMENT" + else: + print "NOT INCREMENT" if context is None: context = {} @@ -3973,12 +3978,12 @@ class stock_pack_operation(osv.osv): if increment: qty += weight else: - qty -= 1 #if qty >= 1 else 0 - #if qty == 0 and op_obj.product_qty == 0: - if qty < 0 and op_obj.product_qty == 0: + if qty == 0 and op_obj.product_qty == 0: #we have a line with 0 qty set, so delete it self.unlink(cr, uid, [operation_id], context=context) return False + else: + qty = max(0, qty-1) #if qty >= 1 else 0 self.write(cr, uid, [operation_id], {'qty_done': qty}, context=context) else: #no existing operation found for the given domain and picking => create a new one