diff --git a/pos_tare/README.rst b/pos_tare/README.rst index 90d9fd00..76c89664 100644 --- a/pos_tare/README.rst +++ b/pos_tare/README.rst @@ -6,67 +6,3 @@ Point Of Sale - Tare !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png - :target: https://odoo-community.org/page/development-status - :alt: Beta -.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 -.. |badge3| image:: https://img.shields.io/badge/github-grap%2Fgrap--odoo--business-lightgray.png?logo=github - :target: https://github.com/grap/grap-odoo-business/tree/8.0/pos_tare - :alt: grap/grap-odoo-business - -|badge1| |badge2| |badge3| - -Give the possibility to the user to provide Gross weight and Tare weight. -This will compute automatically net weight and set it to the current -selected order - -.. figure:: https://raw.githubusercontent.com/grap/grap-odoo-business/8.0/pos_tare/static/description/pos_tare.png - -The screen will be displayed only for 'to_weight' products and if scale is -enabled in PoS Configuration. - -**Table of contents** - -.. contents:: - :local: - -Known issues / Roadmap -====================== - -For the time being, this module disable Scale functionnality. - -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 smashing it by providing a detailed and welcomed -`feedback `_. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Authors -~~~~~~~ - -* GRAP - -Contributors -~~~~~~~~~~~~ - -* Sylvain LE GAL (https://www.twitter.com/legalsylvain) - -Maintainers -~~~~~~~~~~~ - - - -This module is part of the `grap/grap-odoo-business `_ project on GitHub. - - -You are welcome to contribute. diff --git a/pos_tare/__init__.py b/pos_tare/__init__.py index 57d631c3..e69de29b 100644 --- a/pos_tare/__init__.py +++ b/pos_tare/__init__.py @@ -1 +0,0 @@ -# coding: utf-8 diff --git a/pos_tare/__openerp__.py b/pos_tare/__manifest__.py similarity index 51% rename from pos_tare/__openerp__.py rename to pos_tare/__manifest__.py index 851ae5df..0f374eeb 100644 --- a/pos_tare/__openerp__.py +++ b/pos_tare/__manifest__.py @@ -1,4 +1,3 @@ -# coding: utf-8 # 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). @@ -6,14 +5,15 @@ { "name": "Point Of Sale - Tare", "summary": "Manage Tare in Point Of Sale module", - "version": "8.0.1.0.0", + "version": "12.0.1.0.0", "category": "Point Of Sale", - "author": "GRAP", - "website": "http://www.grap.coop", + "author": "GRAP, " + "Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "website": "https://www.github.com/pos", "license": "AGPL-3", - "depends": ["point_of_sale",], - "data": ["views/templates.xml",], - "demo": ["demo/pos_config.xml",], - "qweb": ["static/src/xml/pos_tare.xml",], - "installable": False, + "depends": ["point_of_sale"], + "data": ["views/assets.xml"], + "qweb": ["static/src/xml/pos_tare.xml"], + "installable": True, } diff --git a/pos_tare/demo/pos_config.xml b/pos_tare/demo/pos_config.xml deleted file mode 100644 index 24f196eb..00000000 --- a/pos_tare/demo/pos_config.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - diff --git a/pos_tare/i18n/fr.po b/pos_tare/i18n/fr.po index e349010c..58c64ac3 100644 --- a/pos_tare/i18n/fr.po +++ b/pos_tare/i18n/fr.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-06-21 10:31+0000\n" -"PO-Revision-Date: 2016-06-21 10:31+0000\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" @@ -17,52 +17,35 @@ msgstr "" #. module: pos_tare #. openerp-web -#: code:addons/pos_tare/static/src/js/pos_tare.js:65 -#, python-format -msgid "Back" -msgstr "Retour" - -#. module: pos_tare -#. openerp-web -#: code:addons/pos_tare/static/src/xml/pos_tare.xml:17 -#: code:addons/pos_tare/static/src/xml/pos_tare.xml:18 +#: 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/xml/pos_tare.xml:31 +#: code:addons/pos_tare/static/src/js/screens.js:49 #, python-format -msgid "Net Weight" -msgstr "Poids Net" +msgid "Incorrect Tare Value" +msgstr "Valeur de tare incorrecte" #. module: pos_tare #. openerp-web -#: code:addons/pos_tare/static/src/js/pos_tare.js:73 +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:19 #, python-format -msgid "Order" -msgstr "Commander" +msgid "Kg" +msgstr "Kg" #. module: pos_tare #. openerp-web -#: code:addons/pos_tare/static/src/xml/pos_tare.xml:21 -#: code:addons/pos_tare/static/src/xml/pos_tare.xml:22 +#: code:addons/pos_tare/static/src/js/screens.js:50 #, python-format -msgid "Tare" -msgstr "Tare" +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:35 +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:15 #, python-format -msgid "Total Price" -msgstr "Prix Total" - -#. module: pos_tare -#. openerp-web -#: code:addons/pos_tare/static/src/xml/pos_tare.xml:26 -#, python-format -msgid "Unit Price" -msgstr "Prix Unitaire" - +msgid "Tare" +msgstr "Tare" diff --git a/pos_tare/readme/CONFIGURE.rst b/pos_tare/readme/CONFIGURE.rst new file mode 100644 index 00000000..fcc6833e --- /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/DESCRIPTION.rst b/pos_tare/readme/DESCRIPTION.rst index 609880d2..6d173e68 100644 --- a/pos_tare/readme/DESCRIPTION.rst +++ b/pos_tare/readme/DESCRIPTION.rst @@ -1,8 +1,6 @@ -Give the possibility to the user to provide Gross weight and Tare weight. +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 - -The screen will be displayed only for 'to_weight' products and if scale is -enabled in PoS Configuration. diff --git a/pos_tare/readme/ROADMAP.rst b/pos_tare/readme/ROADMAP.rst index f8cb11be..bfa91b69 100644 --- a/pos_tare/readme/ROADMAP.rst +++ b/pos_tare/readme/ROADMAP.rst @@ -1 +1,2 @@ -For the time being, this module disable Scale functionnality. +* 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/pos_tare.png b/pos_tare/static/description/pos_tare.png index c016216d..2738e6f0 100644 Binary files a/pos_tare/static/description/pos_tare.png 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 index 7837203d..0c72e7ed 100644 --- a/pos_tare/static/src/css/pos_tare.css +++ b/pos_tare/static/src/css/pos_tare.css @@ -1,31 +1,49 @@ -.pos .pos-tare-container .left-block{ + +.pos .scale-screen .weight-label { + font-size: 25px; + margin: 16px; + text-align: center; display: inline-block; - width:45%; - margin:0; - padding:0; - text-align:left; - font-size: 16px; - color: #555; - font-weight: bold; + width: 40%; + margin-bottom: 0px; } -.pos .pos-tare-container .right-block, .pos .pos-tare-container .right-block-readonly{ +.pos .scale-screen .weight-value { + font-size: 25px; display: inline-block; - width:45%; - text-align:right; - height: 40px; - font-size: 20px; - font-family: Lato; - -moz-box-sizing: border-box; - outline: none; - border: none; - padding: 6px 8px; - color: #484848; - border-radius: 3px; - margin-top: 5px; + 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 .pos-tare-container .right-block{ +.pos .scale-screen .weight-value-gross-weight { + border-radius: 3px; + box-shadow: 0px 2px 0px rgb(225,225,225) inset; + text-align: right; background: white; - box-shadow: 0px 2px rgba(143, 143, 143, 0.3) inset; +} + +.pos .scale-screen .weight-value-tare { + text-align: left; + padding-bottom: 0px; + padding-left: 0px; +} +.pos .scale-screen .input-weight-tare { + 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-tare:focus { + outline: none; + box-shadow: 0px 0px 0px 3px #6EC89B; } diff --git a/pos_tare/static/src/js/pos_tare.js b/pos_tare/static/src/js/pos_tare.js deleted file mode 100644 index 2f512f8d..00000000 --- a/pos_tare/static/src/js/pos_tare.js +++ /dev/null @@ -1,140 +0,0 @@ -/* -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). -*/ - -"use strict"; - -openerp.pos_tare = function(instance){ - var module = instance.point_of_sale; - var _t = instance.web._t; - - /************************************************************************* - Extend : Widget 'PosWidget' - */ - module.PosWidget = module.PosWidget.extend({ - build_widgets: function(){ - this._super(); - - // Add a new screen 'TareScreenWidget' - this.tare_screen = new module.TareScreenWidget(this,{}); - this.tare_screen.appendTo(this.$('.screens')); - this.screen_selector.add_screen('tare', this.tare_screen); - }, - }); - - /************************************************************************* - Extend : Widget 'ScaleScreenWidget' - */ - module.ScaleScreenWidget = module.ScaleScreenWidget.extend({ - next_screen: 'tare', - - // Overwrite 'show' function to display TareScreenWidget - show: function(){ - this.pos_widget.screen_selector.set_current_screen(this.next_screen,{product: this.get_product()}); - }, - }); - - /************************************************************************* - Define : New Widget 'TareScreenWidget' - */ - module.TareScreenWidget = module.ScreenWidget.extend({ - template:'TareScreenWidget', - next_screen: 'products', - previous_screen: 'products', - show_leftpane: false, - - show: function(){ - this._super(); - this.renderElement(); - var self = this; - - // Initialize values - this.net_weight = 0; - this.current_product = this.get_product(); - this.$('#product-name').html(this.get_product().display_name); - this.$('#unit-price').html(this.format_currency(this.get_product().price)); - - // Add a 'next' Button - this.add_action_button({ - label: _t('Back'), - icon: '/point_of_sale/static/src/img/icons/png48/go-previous.png', - click: function(){ - self.pos_widget.screen_selector.set_current_screen(self.previous_screen); - }, - }); - this.order_button = this.add_action_button({ - label: _t('Order'), - icon: '/point_of_sale/static/src/img/icons/png48/go-next.png', - click: function() { self.order_product_click(); }, - }); - - // Initialize Display - this.onChangeGrossWeightTareWeight(); - - this.$('#gross-weight').keyup(function(event){ - self.onChangeGrossWeightTareWeight(event); - }); - this.$('#tare-weight').keyup(function(event){ - self.onChangeGrossWeightTareWeight(event); - }); - - // Focus on Gross Weight - this.$('#gross-weight').focus(); - - }, - - sanitize_value: function (input_name){ - var res = this.$(input_name)[0].value.replace(',', '.').trim(); - if (isNaN(res)){ - this.$(input_name).css("background-color", "#F66"); - } - else{ - this.$(input_name).css("background-color", "#FFF"); - } - return res; - }, - - onChangeGrossWeightTareWeight: function(event){ - var gross_weight = this.sanitize_value('#gross-weight'); - var tare_weight = this.sanitize_value('#tare-weight'); - var ok = false; - - if (!isNaN(gross_weight) && (gross_weight !== '') && (parseFloat(gross_weight) !== 0) && !isNaN(tare_weight)){ - this.net_weight = gross_weight - tare_weight; - var price = this.get_product().price * this.net_weight; - this.current_net_weight_text = this.net_weight.toFixed(3); - this.current_total_price_text = this.format_currency(price); - ok = true; - } - else{ - this.current_net_weight_text = '/'; - this.current_total_price_text = '/'; - } - this.$('#net-weight').html(this.current_net_weight_text); - this.$('#total-price').html(this.current_total_price_text); - this.order_button.set_disabled(!ok); - }, - - get_product: function(){ - var ss = this.pos_widget.screen_selector; - if(ss){ - return ss.get_current_screen_param('product'); - }else{ - return undefined; - } - }, - - order_product_click: function(){ - this.pos.get('selectedOrder').addProduct(this.current_product,{ quantity:this.net_weight }); - this.pos_widget.screen_selector.set_current_screen(this.next_screen); - }, - - }); -}; - - - - - diff --git a/pos_tare/static/src/js/screens.js b/pos_tare/static/src/js/screens.js new file mode 100644 index 00000000..849a6df3 --- /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; + this.correct_value = true; + var self = this; + this.$('#weight_tare').keyup(function(event){ + self.onchange_tare(event); + }); + }, + + // 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.$('.weight-value-gross-weight').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('#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 res; + } + }, + + }); + +}); diff --git a/pos_tare/static/src/xml/pos_tare.xml b/pos_tare/static/src/xml/pos_tare.xml index 03376d15..e370d1cd 100644 --- a/pos_tare/static/src/xml/pos_tare.xml +++ b/pos_tare/static/src/xml/pos_tare.xml @@ -6,40 +6,19 @@ Copyright (C) 2015-Today GRAP (http://www.grap.coop) --> - -
-
-
-

-

-
-
- Unit Price - -
-
- Gross Weight - -
-
- Tare - -
-
-
-
- Net Weight - -
-
-
- Total Price - -
- -
+ + +
+ Gross Weight +
+
+
+ Tare +
+
+ Kg
-
+
diff --git a/pos_tare/views/templates.xml b/pos_tare/views/assets.xml similarity index 50% rename from pos_tare/views/templates.xml rename to pos_tare/views/assets.xml index 3cb9b166..9b5d4764 100644 --- a/pos_tare/views/templates.xml +++ b/pos_tare/views/assets.xml @@ -5,19 +5,13 @@ Copyright (C) 2015-Today GRAP (http://www.grap.coop) License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). --> - - - + - -