From d468af06555b2774c31c821eb8843e0558e65426 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 16 Mar 2018 14:54:51 +0100 Subject: [PATCH] [IMP] pos_lot_selection: clone control no longer needed With PR https://github.com/odoo/odoo/pull/23698 merged, clone control is no longer needed for lots. [FIX] pos_lot_selection: group lots by quants fixup! [FIX] pos_lot_selection: group lots by quants fixup! fixup! [FIX] pos_lot_selection: group lots by quants --- pos_lot_selection/README.rst | 2 -- pos_lot_selection/static/src/js/chrome.js | 28 +++-------------------- pos_lot_selection/static/src/js/models.js | 11 +++++---- pos_lot_selection/static/src/xml/pos.xml | 3 --- 4 files changed, 9 insertions(+), 35 deletions(-) diff --git a/pos_lot_selection/README.rst b/pos_lot_selection/README.rst index e7709f37..0580ada4 100644 --- a/pos_lot_selection/README.rst +++ b/pos_lot_selection/README.rst @@ -29,8 +29,6 @@ Usage * There is a new select field with the lots available for that product. * If lot quantity can't cover the order line demand it won't be available to pick. -* If there were many lots to fill the value of one of them can be propagated to - the rest with the new clone control on the right of the lot field. .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot diff --git a/pos_lot_selection/static/src/js/chrome.js b/pos_lot_selection/static/src/js/chrome.js index 36b4f757..c777581b 100644 --- a/pos_lot_selection/static/src/js/chrome.js +++ b/pos_lot_selection/static/src/js/chrome.js @@ -13,7 +13,6 @@ odoo.define("pos_lot_selection.chrome", function (require) { // Add events over instanced popup var events = { "change .packlot-line-select": "lot_to_input", - "click .lot-clone": "clone_input", }; packlotline.events = Object.assign( packlotline.events, events @@ -21,39 +20,18 @@ odoo.define("pos_lot_selection.chrome", function (require) { // Add methods over instanced popup // Write the value in the corresponding input packlotline.lot_to_input = function (event) { - var $select = this.$("select.packlot-line-select"); + var $select = $(event.target); var $option = this.$("select.packlot-line-select option"); - var $input = this.$el.find("input[cid='" + this.active_cid + "']"); + var $input = this.$el.find("input"); if ($input.length) { $input[0].value = $select[0].value; + $input.blur(); $input.focus(); } $option.prop('selected', function () { return this.defaultSelected; }); }; - // Tracks the last selected input - packlotline.lose_input_focus = function (event) { - var $input = $(event.target), - cid = $input.attr('cid'); - this.active_cid = cid; - var lot_model = this.options.pack_lot_lines.get({cid: cid}); - lot_model.set_lot_name($input.val()); - }; - // Clones content of input to all the others - packlotline.clone_input = function (event) { - var $input = $(event.target).prev().prev(), - cid = $input.attr('cid'); - var $clone_input = this.$el.find("input"); - if ($clone_input.length > 1) { - for (var i = 0; i < $clone_input.length; i++) { - if ($clone_input[i].getAttribute('cid') != cid) { - $clone_input[i].value = $input.val(); - $clone_input[i].blur(); - } - } - } - }; this.gui.popup_instances.packlotline = packlotline; return res; }, diff --git a/pos_lot_selection/static/src/js/models.js b/pos_lot_selection/static/src/js/models.js index c2a34f1a..c376f73f 100644 --- a/pos_lot_selection/static/src/js/models.js +++ b/pos_lot_selection/static/src/js/models.js @@ -17,13 +17,14 @@ odoo.define("pos_lot_selection.models", function (require) { ["product_id", "=", product], ["lot_id", "!=", false]] }, {'async': false}).then(function (result) { - var product_lot = []; + var product_lot = {}; if (result.length) { for (var i = 0; i < result.length; i++) { - product_lot.push({ - 'lot_name': result.records[i].lot_id[1], - 'quantity': result.records[i].quantity, - }); + if (product_lot[result.records[i].lot_id[1]]) { + product_lot[result.records[i].lot_id[1]] += result.records[i].quantity; + } else { + product_lot[result.records[i].lot_id[1]] = result.records[i].quantity; + } } } done.resolve(product_lot); diff --git a/pos_lot_selection/static/src/xml/pos.xml b/pos_lot_selection/static/src/xml/pos.xml index 13e1ac12..fab7bf71 100644 --- a/pos_lot_selection/static/src/xml/pos.xml +++ b/pos_lot_selection/static/src/xml/pos.xml @@ -19,9 +19,6 @@ - - -