diff --git a/pos_tare/README.rst b/pos_tare/README.rst new file mode 100644 index 00000000..90d9fd00 --- /dev/null +++ b/pos_tare/README.rst @@ -0,0 +1,72 @@ +==================== +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 new file mode 100644 index 00000000..57d631c3 --- /dev/null +++ b/pos_tare/__init__.py @@ -0,0 +1 @@ +# coding: utf-8 diff --git a/pos_tare/__openerp__.py b/pos_tare/__openerp__.py new file mode 100644 index 00000000..ed850269 --- /dev/null +++ b/pos_tare/__openerp__.py @@ -0,0 +1,27 @@ +# 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). + +{ + 'name': 'Point Of Sale - Tare', + 'summary': 'Manage Tare in Point Of Sale module', + 'version': '8.0.1.0.0', + 'category': 'Point Of Sale', + 'author': 'GRAP', + 'website': 'http://www.grap.coop', + '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, +} diff --git a/pos_tare/demo/pos_config.xml b/pos_tare/demo/pos_config.xml new file mode 100644 index 00000000..24f196eb --- /dev/null +++ b/pos_tare/demo/pos_config.xml @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/pos_tare/i18n/fr.po b/pos_tare/i18n/fr.po new file mode 100644 index 00000000..e349010c --- /dev/null +++ b/pos_tare/i18n/fr.po @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_tare +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.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" +"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/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 +#, python-format +msgid "Gross Weight" +msgstr "Poids Brut" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:31 +#, python-format +msgid "Net Weight" +msgstr "Poids Net" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/js/pos_tare.js:73 +#, python-format +msgid "Order" +msgstr "Commander" + +#. 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 +#, python-format +msgid "Tare" +msgstr "Tare" + +#. module: pos_tare +#. openerp-web +#: code:addons/pos_tare/static/src/xml/pos_tare.xml:35 +#, 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" + diff --git a/pos_tare/readme/CONTRIBUTORS.rst b/pos_tare/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..e1525ce0 --- /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 00000000..609880d2 --- /dev/null +++ b/pos_tare/readme/DESCRIPTION.rst @@ -0,0 +1,8 @@ +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:: ../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 new file mode 100644 index 00000000..f8cb11be --- /dev/null +++ b/pos_tare/readme/ROADMAP.rst @@ -0,0 +1 @@ +For the time being, this module disable Scale functionnality. diff --git a/pos_tare/static/description/icon.png b/pos_tare/static/description/icon.png new file mode 100644 index 00000000..821c4b3b 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 00000000..c016216d 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 00000000..7837203d --- /dev/null +++ b/pos_tare/static/src/css/pos_tare.css @@ -0,0 +1,31 @@ +.pos .pos-tare-container .left-block{ + display: inline-block; + width:45%; + margin:0; + padding:0; + text-align:left; + font-size: 16px; + color: #555; + font-weight: bold; +} + +.pos .pos-tare-container .right-block, .pos .pos-tare-container .right-block-readonly{ + 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; +} + +.pos .pos-tare-container .right-block{ + background: white; + box-shadow: 0px 2px rgba(143, 143, 143, 0.3) inset; +} diff --git a/pos_tare/static/src/js/pos_tare.js b/pos_tare/static/src/js/pos_tare.js new file mode 100644 index 00000000..2f512f8d --- /dev/null +++ b/pos_tare/static/src/js/pos_tare.js @@ -0,0 +1,140 @@ +/* +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/xml/pos_tare.xml b/pos_tare/static/src/xml/pos_tare.xml new file mode 100644 index 00000000..03376d15 --- /dev/null +++ b/pos_tare/static/src/xml/pos_tare.xml @@ -0,0 +1,45 @@ + + + + + +
+
+
+

+

+
+
+ Unit Price + +
+
+ Gross Weight + +
+
+ Tare + +
+
+
+
+ Net Weight + +
+
+
+ Total Price + +
+ +
+
+
+
+ +
diff --git a/pos_tare/views/templates.xml b/pos_tare/views/templates.xml new file mode 100644 index 00000000..3cb9b166 --- /dev/null +++ b/pos_tare/views/templates.xml @@ -0,0 +1,23 @@ + + + + + + + + + + +