From e85e166d26e0314b7b98c24e93c757a61562b0da Mon Sep 17 00:00:00 2001 From: Ignacio Ales Date: Thu, 30 Aug 2018 10:11:53 +0200 Subject: [PATCH] [MIG] pos_lot_selection: Migration to 11.0 --- pos_lot_selection/README.rst | 3 ++- pos_lot_selection/__init__.py | 1 - pos_lot_selection/__manifest__.py | 3 +-- pos_lot_selection/static/src/js/chrome.js | 2 +- pos_lot_selection/static/src/js/models.js | 25 +++++++++++------------ 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pos_lot_selection/README.rst b/pos_lot_selection/README.rst index ef8a32c8..e7709f37 100644 --- a/pos_lot_selection/README.rst +++ b/pos_lot_selection/README.rst @@ -34,7 +34,7 @@ Usage .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/184/10.0 + :target: https://runbot.odoo-community.org/runbot/184/11.0 Known issues / Roadmap ====================== @@ -63,6 +63,7 @@ Contributors * David * (https://www.tecnativa.com) +* Ignacio Ales Do not contact contributors directly about support or help with technical issues. diff --git a/pos_lot_selection/__init__.py b/pos_lot_selection/__init__.py index 40a96afc..e69de29b 100644 --- a/pos_lot_selection/__init__.py +++ b/pos_lot_selection/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/pos_lot_selection/__manifest__.py b/pos_lot_selection/__manifest__.py index c03d0b75..4a1f2dd8 100644 --- a/pos_lot_selection/__manifest__.py +++ b/pos_lot_selection/__manifest__.py @@ -1,10 +1,9 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Tecnativa S.L. - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'POS Lot Selection', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Point of Sale', 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', diff --git a/pos_lot_selection/static/src/js/chrome.js b/pos_lot_selection/static/src/js/chrome.js index addbe32b..36b4f757 100644 --- a/pos_lot_selection/static/src/js/chrome.js +++ b/pos_lot_selection/static/src/js/chrome.js @@ -53,7 +53,7 @@ odoo.define("pos_lot_selection.chrome", function (require) { } } } - } + }; 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 a7d72222..c2a34f1a 100644 --- a/pos_lot_selection/static/src/js/models.js +++ b/pos_lot_selection/static/src/js/models.js @@ -5,25 +5,24 @@ odoo.define("pos_lot_selection.models", function (require) { "use strict"; var models = require("point_of_sale.models"); - var Model = require("web.DataModel"); var session = require("web.session"); models.PosModel = models.PosModel.extend({ - get_lot: function(product, location_id) { + get_lot: function (product, location_id) { var done = new $.Deferred(); session.rpc("/web/dataset/search_read", { "model": "stock.quant", "domain": [ ["location_id", "=", location_id], ["product_id", "=", product], - ["lot_id", "!=", false]], + ["lot_id", "!=", false]] }, {'async': false}).then(function (result) { 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], - 'qty': result.records[i].qty, + 'quantity': result.records[i].quantity, }); } } @@ -39,16 +38,16 @@ odoo.define("pos_lot_selection.models", function (require) { var done = new $.Deferred(); var compute_lot_lines = _orderline_super.compute_lot_lines.apply(this, arguments); this.pos.get_lot(this.product.id, this.pos.config.stock_location_id[0]) - .then(function (product_lot) { - var lot_name = []; - for (var i = 0; i < product_lot.length; i++) { - if (product_lot[i].qty >= compute_lot_lines.order_line.quantity) { - lot_name.push(product_lot[i].lot_name); + .then(function (product_lot) { + var lot_name = Object.keys(product_lot); + for (var i = 0; i < lot_name.length; i++) { + if (product_lot[lot_name[i]] < compute_lot_lines.order_line.quantity) { + lot_name.splice(i, 1); + } } - } - compute_lot_lines.lot_name = lot_name; - done.resolve(compute_lot_lines); - }); + compute_lot_lines.lot_name = lot_name; + done.resolve(compute_lot_lines); + }); return compute_lot_lines; }, });