From d5908083b4c4cdfb34bbdd8e381c1e419c094702 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Tue, 14 Mar 2017 13:33:18 +0100 Subject: [PATCH] [IMP] point_of_sale: indicate on pos picking type the use of lots By unticking the "Use Existing Lots" checkbox on the pos picking type, you can choose not to enter any lots/serial numbers in the pos. This way, the picking will not specify the lots either and the system will take the quants and lots according to the removal strategy. --- addons/point_of_sale/models/pos_config.py | 1 + addons/point_of_sale/models/pos_order.py | 8 ++++++-- addons/point_of_sale/static/src/js/models.js | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 8d511d3b62c..f079fd02cbd 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -62,6 +62,7 @@ class PosConfig(models.Model): 'pos_config_id', 'journal_id', string='Available Payment Methods', domain="[('journal_user', '=', True ), ('type', 'in', ['bank', 'cash'])]",) picking_type_id = fields.Many2one('stock.picking.type', string='Operation Type') + use_existing_lots = fields.Boolean(related='picking_type_id.use_existing_lots') stock_location_id = fields.Many2one( 'stock.location', string='Stock Location', domain=[('usage', '=', 'internal')], required=True, default=_get_default_location) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index c52e2f87084..78c128d9eb6 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -643,13 +643,17 @@ class PosOrder(models.Model): has_wrong_lots = False for order in self: for pack_operation in (picking or self.picking_id).pack_operation_ids: + picking_type = (picking or self.picking_id).picking_type_id + lots_necessary = True + if picking_type: + lots_necessary = picking_type and picking_type.use_existing_lots qty = 0 qty_done = 0 pack_lots = [] pos_pack_lots = PosPackOperationLot.search([('order_id', '=', order.id), ('product_id', '=', pack_operation.product_id.id)]) pack_lot_names = [pos_pack.lot_name for pos_pack in pos_pack_lots] - if pack_lot_names: + if pack_lot_names and lots_necessary: for lot_name in list(set(pack_lot_names)): stock_production_lot = StockProductionLot.search([('name', '=', lot_name), ('product_id', '=', pack_operation.product_id.id)]) if stock_production_lot: @@ -662,7 +666,7 @@ class PosOrder(models.Model): pack_lots.append({'lot_id': stock_production_lot.id, 'qty': qty}) else: has_wrong_lots = True - elif pack_operation.product_id.tracking == 'none': + elif pack_operation.product_id.tracking == 'none' or not lots_necessary: qty_done = pack_operation.product_qty else: has_wrong_lots = True diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index bbc1c482e2a..28a05268d96 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1219,7 +1219,7 @@ exports.Orderline = Backbone.Model.extend({ return orderline; }, set_product_lot: function(product){ - this.has_product_lot = product.tracking !== 'none'; + this.has_product_lot = product.tracking !== 'none' && this.pos.config.use_existing_lots; this.pack_lot_lines = this.has_product_lot && new PacklotlineCollection(null, {'order_line': this}); }, // sets a discount [0,100]%