diff --git a/pos_lot_selection/README.rst b/pos_lot_selection/README.rst new file mode 100644 index 00000000..ef8a32c8 --- /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. +* 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 + :target: https://runbot.odoo-community.org/runbot/184/10.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) + +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..40a96afc --- /dev/null +++ b/pos_lot_selection/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/pos_lot_selection/__manifest__.py b/pos_lot_selection/__manifest__.py new file mode 100644 index 00000000..c03d0b75 --- /dev/null +++ b/pos_lot_selection/__manifest__.py @@ -0,0 +1,24 @@ +# -*- 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', + '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..d107fc5f --- /dev/null +++ b/pos_lot_selection/i18n/es.po @@ -0,0 +1,28 @@ +# 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" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_lot_selection +#: model:ir.model,name:pos_lot_selection.model_stock_quant +msgid "Quants" +msgstr "Quants" + +#. 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" 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..addbe32b --- /dev/null +++ b/pos_lot_selection/static/src/js/chrome.js @@ -0,0 +1,62 @@ +/* Copyright 2018 Tecnativa - David Vidal + 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", + "click .lot-clone": "clone_input", + }; + packlotline.events = Object.assign( + packlotline.events, events + ); + // 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 $option = this.$("select.packlot-line-select option"); + var $input = this.$el.find("input[cid='" + this.active_cid + "']"); + if ($input.length) { + $input[0].value = $select[0].value; + $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 new file mode 100644 index 00000000..a7d72222 --- /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 Model = require("web.DataModel"); + 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++) { + product_lot.push({ + 'lot_name': result.records[i].lot_id[1], + 'qty': result.records[i].qty, + }); + } + } + 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 = []; + 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); + } + } + 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..13e1ac12 --- /dev/null +++ b/pos_lot_selection/static/src/xml/pos.xml @@ -0,0 +1,27 @@ + + + + + + + +
+ + + +
+
+ + + +
+ +
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 @@ + + + + + +