[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) <len@odoo.com>
This commit is contained in:
Gert Pellin
2019-05-22 13:25:10 +00:00
parent ec2ea9b08d
commit d92e0cb1cf
+6 -3
View File
@@ -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);
}
}
});