diff --git a/pos_lot_selection/README.rst b/pos_lot_selection/README.rst new file mode 100644 index 00000000..c7c425a1 --- /dev/null +++ b/pos_lot_selection/README.rst @@ -0,0 +1,82 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +================= +POS Lot Selection +================= + +This module allows to pick between existing lots in POS frontend. + +Configuration +============= + +1. Go to *Inventory > Settings* and set the option *Track lots or serial + numbers* +2. Chose a product that is stockable, go to its *Inventory* + tab, and set *Tracking* to *By Lots*. +3. Go to its *Sales* tab and set it as *Available in the Point of Sale*. +4. Click on *Update Qty On Hand*, chose the same location configured in the + POS you want the lot available in; write a quantity; unfold the *Lot/Serial + Number* field and pick create one if none is available yet. +5. Create a new lot with the serial number of your choice. + +Usage +===== + +* Open a POS Session. +* Choose a product with required lot. +* 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. + +.. 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/12.0 + +Known issues / Roadmap +====================== + +* Lot selection is only available when the POS is online. In offline mode the + select isn't loaded and the lot has to be manually set. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* David + * (https://www.tecnativa.com) +* Ignacio Ales +* Kiril Vangelovski + +Do not contact contributors directly about support or help with technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/pos_lot_selection/__init__.py b/pos_lot_selection/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/pos_lot_selection/__manifest__.py b/pos_lot_selection/__manifest__.py new file mode 100644 index 00000000..23ac10ed --- /dev/null +++ b/pos_lot_selection/__manifest__.py @@ -0,0 +1,23 @@ +# 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': '12.0.1.0.0', + 'category': 'Point of Sale', + 'author': 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/pos', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'templates/assets.xml', + ], + 'qweb': [ + 'static/src/xml/pos.xml' + ], + 'application': False, + 'installable': True, +} diff --git a/pos_lot_selection/i18n/es.po b/pos_lot_selection/i18n/es.po new file mode 100644 index 00000000..eaad09c5 --- /dev/null +++ b/pos_lot_selection/i18n/es.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_lot_selection +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-03-13 09:16+0000\n" +"PO-Revision-Date: 2018-03-13 09:16+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/pos.xml:12 +#, python-format +msgid "Select a Serial/Lot Number" +msgstr "Escoja un nÂș de Serie / de Lote" + +#~ msgid "Quants" +#~ msgstr "Quants" diff --git a/pos_lot_selection/i18n/pos_lot_selection.pot b/pos_lot_selection/i18n/pos_lot_selection.pot new file mode 100644 index 00000000..b262419a --- /dev/null +++ b/pos_lot_selection/i18n/pos_lot_selection.pot @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_lot_selection +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_lot_selection +#. openerp-web +#: code:addons/pos_lot_selection/static/src/xml/pos.xml:12 +#, python-format +msgid "Select a Serial/Lot Number" +msgstr "" + diff --git a/pos_lot_selection/static/description/icon.png b/pos_lot_selection/static/description/icon.png new file mode 100644 index 00000000..ca2e8601 Binary files /dev/null and b/pos_lot_selection/static/description/icon.png differ diff --git a/pos_lot_selection/static/src/css/pos.css b/pos_lot_selection/static/src/css/pos.css new file mode 100644 index 00000000..de079d71 --- /dev/null +++ b/pos_lot_selection/static/src/css/pos.css @@ -0,0 +1,29 @@ +/* Copyright 2018 Tecnativa - David Vidal + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +*/ + +.pos .popup .packlot-select { + border-bottom: solid 1px rgba(60,60,60,0.1); + margin-top: 3px; +} + +.pos .popup select { + text-align: left; + padding: 10px; + display: inline-block; + border-radius: 3px; + border: solid 1px #cecbcb; + margin-bottom: 4px; + background: white; + font-family: "Lato","Lucida Grande", Helvetica, Verdana, Arial; + color: #444; + width: 80%; + min-height: 44px; + font-size: 20px; + box-sizing: border-box; +} + +.pos .popup select:focus, .pos .popup select:active { + outline: none; + box-shadow: 0px 0px 0px 3px #6EC89B; +} diff --git a/pos_lot_selection/static/src/js/chrome.js b/pos_lot_selection/static/src/js/chrome.js new file mode 100644 index 00000000..8714a7d1 --- /dev/null +++ b/pos_lot_selection/static/src/js/chrome.js @@ -0,0 +1,41 @@ +/* Copyright 2018 Tecnativa - David Vidal + Copyright 2019 Lambda IS DOOEL + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + +odoo.define("pos_lot_selection.chrome", function (require) { + "use strict"; + + var chrome = require("point_of_sale.chrome"); + + chrome.Chrome.include({ + build_widgets: function () { + var res = this._super.apply(this, arguments); + var packlotline = this.gui.popup_instances.packlotline; + // Add events over instanced popup + var events = { + "change .packlot-line-select": "lot_to_input", + }; + packlotline.events = _.extend( + packlotline.events, events + ); + // Add methods over instanced popup + // Write the value in the corresponding input + packlotline.lot_to_input = function (event) { + var $select = $(event.target); + var $option = this.$("select.packlot-line-select option"); + 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; + }); + }; + 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 new file mode 100644 index 00000000..c376f73f --- /dev/null +++ b/pos_lot_selection/static/src/js/models.js @@ -0,0 +1,56 @@ +/* Copyright 2018 Tecnativa - David Vidal + License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). */ + +odoo.define("pos_lot_selection.models", function (require) { + "use strict"; + + var models = require("point_of_sale.models"); + var session = require("web.session"); + + models.PosModel = models.PosModel.extend({ + 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]] + }, {'async': false}).then(function (result) { + var product_lot = {}; + if (result.length) { + for (var i = 0; i < result.length; i++) { + 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); + }); + return done; + }, + }); + + var _orderline_super = models.Orderline.prototype; + models.Orderline = models.Orderline.extend({ + compute_lot_lines: function(){ + 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 = 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); + }); + return compute_lot_lines; + }, + }); + +}); diff --git a/pos_lot_selection/static/src/xml/pos.xml b/pos_lot_selection/static/src/xml/pos.xml new file mode 100644 index 00000000..fab7bf71 --- /dev/null +++ b/pos_lot_selection/static/src/xml/pos.xml @@ -0,0 +1,24 @@ + + + + + + + +
+ + + +
+
+
+ +
diff --git a/pos_lot_selection/templates/assets.xml b/pos_lot_selection/templates/assets.xml new file mode 100644 index 00000000..e5552f52 --- /dev/null +++ b/pos_lot_selection/templates/assets.xml @@ -0,0 +1,15 @@ + + + + + +