diff --git a/pos_tare/README.rst b/pos_tare/README.rst new file mode 100644 index 0000000000..76c8966496 --- /dev/null +++ b/pos_tare/README.rst @@ -0,0 +1,8 @@ +==================== +Point Of Sale - Tare +==================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/pos_tare/__init__.py b/pos_tare/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pos_tare/__manifest__.py b/pos_tare/__manifest__.py new file mode 100644 index 0000000000..6c6d86bfce --- /dev/null +++ b/pos_tare/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright (C) 2015-Today GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + "name": "Point Of Sale - Tare", + "summary": "Manage Tare in Point Of Sale module", + "version": "12.0.1.0.0", + "category": "Point Of Sale", + "author": "GRAP, " + "Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "website": "https://www.github.com/OCA/pos", + "license": "AGPL-3", + "depends": ["point_of_sale"], + "data": ["views/assets.xml"], + "qweb": ["static/src/xml/pos_tare.xml"], + "installable": True, + "images": ["static/description/pos_tare.png"], +} diff --git a/pos_tare/i18n/fr.po b/pos_tare/i18n/fr.po new file mode 100644 index 0000000000..58c64ac38e --- /dev/null +++ b/pos_tare/i18n/fr.po @@ -0,0 +1,51 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_tare +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-01-08 15:03+0000\n" +"PO-Revision-Date: 2020-01-08 15:03+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_tare +#. openerp-web +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:11 +#, python-format +msgid "Gross Weight" +msgstr "Poids Brut" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/js/screens.js:49 +#, python-format +msgid "Incorrect Tare Value" +msgstr "Valeur de tare incorrecte" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:19 +#, python-format +msgid "Kg" +msgstr "Kg" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/js/screens.js:50 +#, python-format +msgid "Please set a numeric value in the tare field, or let empty." +msgstr "Veuillez saisir une valeur numérique dans le champ 'tare', ou le laisser vide." + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:15 +#, python-format +msgid "Tare" +msgstr "Tare" diff --git a/pos_tare/readme/CONFIGURE.rst b/pos_tare/readme/CONFIGURE.rst new file mode 100644 index 0000000000..fcc6833ebc --- /dev/null +++ b/pos_tare/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +To enable this feature, you should enable "IoT Box" on your Point of Sale, +and check the box "Electronic Scale" diff --git a/pos_tare/readme/CONTRIBUTORS.rst b/pos_tare/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..e1525ce042 --- /dev/null +++ b/pos_tare/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL (https://www.twitter.com/legalsylvain) diff --git a/pos_tare/readme/DESCRIPTION.rst b/pos_tare/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..6d173e68ad --- /dev/null +++ b/pos_tare/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +Give the possibility to the user to enter a Tare weight, when weighting +products in the Point of Sale. +This will compute automatically net weight and set it to the current +selected order + +.. figure:: ../static/description/pos_tare.png diff --git a/pos_tare/readme/ROADMAP.rst b/pos_tare/readme/ROADMAP.rst new file mode 100644 index 0000000000..bfa91b6907 --- /dev/null +++ b/pos_tare/readme/ROADMAP.rst @@ -0,0 +1,2 @@ +* Display the gross weight and the tare on each order line, on the screen + and on the receipt. diff --git a/pos_tare/static/description/icon.png b/pos_tare/static/description/icon.png new file mode 100644 index 0000000000..821c4b3bab Binary files /dev/null and b/pos_tare/static/description/icon.png differ diff --git a/pos_tare/static/description/pos_tare.png b/pos_tare/static/description/pos_tare.png new file mode 100644 index 0000000000..2738e6f0b2 Binary files /dev/null and b/pos_tare/static/description/pos_tare.png differ diff --git a/pos_tare/static/src/css/pos_tare.css b/pos_tare/static/src/css/pos_tare.css new file mode 100644 index 0000000000..ff7af4bd02 --- /dev/null +++ b/pos_tare/static/src/css/pos_tare.css @@ -0,0 +1,49 @@ + +.pos .scale-screen .weight-label { + font-size: 25px; + margin: 16px; + text-align: center; + display: inline-block; + width: 40%; + margin-bottom: 0px; +} + +.pos .scale-screen .weight-value { + font-size: 25px; + display: inline-block; + margin: 16px; + margin-top: 0px; + padding: 16px; + width: 40%; + font-family: Inconsolata; + font-weight: bold; + text-shadow: 0px 2px 0px rgb(210,210,210); + margin-bottom: 0px; +} + +.pos .scale-screen .weight-value-fixed { + border-radius: 3px; + box-shadow: 0px 2px 0px rgb(225,225,225) inset; + text-align: right; + background: white; +} + +.pos .scale-screen .weight-value-alterable { + text-align: left; + padding-bottom: 0px; + padding-left: 0px; +} +.pos .scale-screen .input-weight { + border: 1px solid #cecbcb; + border-radius: 20px; + padding: 15px 20px; + width: 50%; + font-family: Inconsolata; + font-weight: bold; + font-size: 25px; +} + +.pos .scale-screen .input-weight:focus { + outline: none; + box-shadow: 0px 0px 0px 3px #6EC89B; +} diff --git a/pos_tare/static/src/js/screens.js b/pos_tare/static/src/js/screens.js new file mode 100644 index 0000000000..6ee161b58a --- /dev/null +++ b/pos_tare/static/src/js/screens.js @@ -0,0 +1,97 @@ +/* +Copyright (C) 2015-Today GRAP (http://www.grap.coop) +@author: Sylvain LE GAL (https://twitter.com/legalsylvain) + License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +*/ + + +odoo.define('pos_tare.screens', function (require) { + "use strict"; + + var screens = require('point_of_sale.screens'); + var utils = require('web.utils'); + var round_pr = utils.round_precision; + + + screens.ScaleScreenWidget.include({ + + // ///////////////////////////// + // Overload Section + // ///////////////////////////// + + // Overload show function + // add an handler on the + show: function(){ + this._super(); + this.tare = 0.0; + var self = this; + this.$('#input_weight_tare').keyup(function(event){ + self.onchange_tare(event); + }); + this.$('#input_weight_tare').focus() + }, + + // Overload set_weight function + // We assume that the argument is now the gross weight + // we compute the net weight, depending on the tare and the gross weight + // then we call super, with the net weight + set_weight: function(gross_weight){ + this.gross_weight = gross_weight; + var net_weight = gross_weight - (this.tare || 0); + this.$('#container_weight_gross').text(this.get_product_gross_weight_string()); + this._super(net_weight); + }, + + order_product: function(){ + // TODO Set a warning, if the value is incorrect; + if (this.tare === undefined) { + this.gui.show_popup('error',{ + 'title': _t('Incorrect Tare Value'), + 'body': _t('Please set a numeric value in the tare field, or let empty.'), + }); + } + else { + this._super(); + } + }, + + // ///////////////////////////// + // Custom Section + // ///////////////////////////// + get_product_gross_weight_string: function(){ + var product = this.get_product(); + var defaultstr = (this.gross_weight || 0).toFixed(3) + ' Kg'; + if(!product || !this.pos){ + return defaultstr; + } + var unit_id = product.uom_id; + if(!unit_id){ + return defaultstr; + } + var unit = this.pos.units_by_id[unit_id[0]]; + var weight = round_pr(this.gross_weight || 0, unit.rounding); + var weightstr = weight.toFixed(Math.ceil(Math.log(1.0/unit.rounding) / Math.log(10) )); + weightstr += ' ' + unit.name; + return weightstr; + }, + + onchange_tare: function(event){ + this.tare = this.check_sanitize_value('#input_weight_tare');; + this.set_weight(this.gross_weight); + }, + + check_sanitize_value: function (input_name){ + var res = this.$(input_name)[0].value.replace(',', '.').trim(); + if (isNaN(res)){ + this.$(input_name).css("background-color", "#F66"); + return undefined; + } + else{ + this.$(input_name).css("background-color", "#FFF"); + return parseFloat(res, 10); + } + }, + + }); + +}); diff --git a/pos_tare/static/src/xml/pos_tare.xml b/pos_tare/static/src/xml/pos_tare.xml new file mode 100644 index 0000000000..14d2e74d1a --- /dev/null +++ b/pos_tare/static/src/xml/pos_tare.xml @@ -0,0 +1,24 @@ + + + + + + +
+ Gross Weight +
+
+
+ Tare +
+
+ Kg +
+ + + + diff --git a/pos_tare/views/assets.xml b/pos_tare/views/assets.xml new file mode 100644 index 0000000000..9b5d47641e --- /dev/null +++ b/pos_tare/views/assets.xml @@ -0,0 +1,17 @@ + + + + + +