From 025d9432a1dfc1db484e9e65d2748ed91d67ca26 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 8 Feb 2017 15:25:44 -0800 Subject: [PATCH] [IMP] point_of_sale: handle products tracked as lots The POS support for tracked products implemented at 8f39c652c65c81d87503d64eeef0da3e0048ffc9 was mainly meant for products tracked with serial numbers. In theory it would also work for lots as long as the lots were only sold in integer quantities. One could specify the same lot multiple times. For products tracked in non-integer quantities this wouldn't work however. This commit makes the POS handle lots more like the stock module. When a product tracked in lots is bought in the POS you can only specify one lot number. If a product is sold from multiple lots then multiple order lines have to be specified. Fixes #15325 --- addons/point_of_sale/models/pos_order.py | 3 +- addons/point_of_sale/static/src/js/models.js | 33 +++++++++++++++----- addons/point_of_sale/static/src/js/popups.js | 3 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index a72c87cef52..11263840180 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -654,7 +654,8 @@ class PosOrder(models.Model): stock_production_lot = StockProductionLot.search([('name', '=', lot_name), ('product_id', '=', pack_operation.product_id.id)]) if stock_production_lot: if stock_production_lot.product_id.tracking == 'lot': - qty = pack_lot_names.count(lot_name) + # if a lot nr is set through the frontend it will refer to the full quantity + qty = pack_operation.product_qty else: qty = 1.0 qty_done += qty diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 87ce0480022..bbc1c482e2a 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1282,16 +1282,28 @@ exports.Orderline = Backbone.Model.extend({ } }, + get_required_number_of_lots: function(){ + var lots_required = 1; + + if (this.product.tracking == 'serial') { + lots_required = this.quantity; + } + + return lots_required; + }, + compute_lot_lines: function(){ var pack_lot_lines = this.pack_lot_lines; var lines = pack_lot_lines.length; - if(this.quantity > lines){ - for(var i=0; i lines){ + for(var i=0; i