From d92e0cb1cf0e8697fc7dddbf307bd8181e491b34 Mon Sep 17 00:00:00 2001 From: Gert Pellin Date: Wed, 22 May 2019 12:27:53 +0000 Subject: [PATCH] [FIX] point_of_sale: return products with serial numbers * Do a product return of a product with serial number required. * Open the dialogue to enter the serial numbers. Current behaviour before PR: * A modal without any input fields will be displayed. Desired behaviour after PR is merged: * The modal has as many input fields as there are products to be returned. The modal is populated by the value of `lots_required`. To get the right value this variable should have the absolute value of the amount of products. After closing the modal there will be a check on the amount of serial numbers given. This will automatically update the amount of the product. Because this value is always positive we have to do a check on the product quantity first to know the sign of the new value. closes odoo/odoo#33535 Signed-off-by: Nans Lefebvre (len) --- addons/point_of_sale/static/src/js/models.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index ec25a5b7373..34a47c689fb 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1472,7 +1472,7 @@ exports.Orderline = Backbone.Model.extend({ var lots_required = 1; if (this.product.tracking == 'serial') { - lots_required = this.quantity; + lots_required = Math.abs(this.quantity); } return lots_required; @@ -1875,8 +1875,11 @@ var PacklotlineCollection = Backbone.Collection.extend({ set_quantity_by_lot: function() { if (this.order_line.product.tracking == 'serial') { - var valid_lots = this.get_valid_lots(); - this.order_line.set_quantity(valid_lots.length); + var valid_lots_quantity = this.get_valid_lots().length; + if (this.order_line.quantity < 0){ + valid_lots_quantity = -valid_lots_quantity; + } + this.order_line.set_quantity(valid_lots_quantity); } } });