From 7cee27f3ffbc4273bb7d1a61e018baccf06de5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Kawala?= Date: Fri, 14 Feb 2020 07:58:59 +0100 Subject: [PATCH] Added: demo UOM, better errors, i18n. --- pos_barcode_tare/__openerp__.py | 1 + .../demo/pos_barcode_tare_demo.xml | 9 ++ pos_barcode_tare/i18n/fr_CH.po | 106 ++++++++++++++---- pos_barcode_tare/i18n/pos_barcode_tare.pot | 92 ++++++++++++--- .../static/src/js/pos_barcode_tare.js | 27 ++++- 5 files changed, 193 insertions(+), 42 deletions(-) create mode 100644 pos_barcode_tare/demo/pos_barcode_tare_demo.xml diff --git a/pos_barcode_tare/__openerp__.py b/pos_barcode_tare/__openerp__.py index 578341f4..8ef3fd09 100644 --- a/pos_barcode_tare/__openerp__.py +++ b/pos_barcode_tare/__openerp__.py @@ -11,6 +11,7 @@ 'website': "https://github.com/OCA/pos", 'license': 'AGPL-3', 'depends': ['point_of_sale'], + 'demo': ['demo/pos_barcode_tare_demo.xml'], 'data': [ 'pos_barcode_tare.xml', 'views/pos_config_view.xml', diff --git a/pos_barcode_tare/demo/pos_barcode_tare_demo.xml b/pos_barcode_tare/demo/pos_barcode_tare_demo.xml new file mode 100644 index 00000000..7b5767bf --- /dev/null +++ b/pos_barcode_tare/demo/pos_barcode_tare_demo.xml @@ -0,0 +1,9 @@ + + + + + Kg + + + + diff --git a/pos_barcode_tare/i18n/fr_CH.po b/pos_barcode_tare/i18n/fr_CH.po index c644d040..3165265b 100644 --- a/pos_barcode_tare/i18n/fr_CH.po +++ b/pos_barcode_tare/i18n/fr_CH.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 18:22+0000\n" -"PO-Revision-Date: 2020-02-05 18:22+0000\n" +"POT-Creation-Date: 2020-02-14 06:44+0000\n" +"PO-Revision-Date: 2020-02-14 06:44+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -23,6 +23,19 @@ msgstr "" msgid "Back" msgstr "Retour" +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:130 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:130 +#, python-format +msgid "Failed to read weight from scale." +msgstr "Failed to read weight from scale." + +#. module: pos_barcode_tare +#: model:product.uom,name:pos_barcode_tare.product_uom_kgm_dbg +msgid "Kg" +msgstr "Kg" + #. module: pos_barcode_tare #: model:ir.ui.view,arch_db:pos_barcode_tare.view_pos_config_form msgid "Loose good options" @@ -30,19 +43,11 @@ msgstr "Options pour la vente en vrac" #. module: pos_barcode_tare #. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:72 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:72 -#, python-format -msgid "Mismatch in units of measure" -msgstr "Erreur d'unitée de mesure" - -#. module: pos_barcode_tare -#. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:89 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:89 +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:196 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:196 #, python-format -msgid "Negative weight" -msgstr "Poids négatif" +msgid "Maximum tare weight is 99.999kg" +msgstr "Le poids mesuré est supérieur au poids maximum pour la tare: 99.999kg" #. module: pos_barcode_tare #. openerp-web @@ -50,7 +55,7 @@ msgstr "Poids négatif" #: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:18 #, python-format msgid "Print" -msgstr "Imprimer" +msgstr "Imprimer l'étiquette" #. module: pos_barcode_tare #. openerp-web @@ -65,7 +70,7 @@ msgstr "Imprimer une étiquette de tare" #. module: pos_barcode_tare #: model:ir.model.fields,help:pos_barcode_tare.field_pos_config_iface_tare_label msgid "Print tare labels with this POS" -msgstr "Utiliser ce POS pour imprimer des étiquettes de tare" +msgstr "Utiliser ce POS pour imprimer les étiquettes de tare" #. module: pos_barcode_tare #. openerp-web @@ -78,7 +83,7 @@ msgstr "Placez le récipient à tarer sur la balance puis vérifiez le poids ci- #. module: pos_barcode_tare #: model:ir.model.fields,field_description:pos_barcode_tare.field_pos_config_iface_tare_label msgid "Show tare label button" -msgstr "Afficher le bouton d'impression sur ce POS" +msgstr "Utiliser ce POS pour imprimer les étiquettes de tare" #. module: pos_barcode_tare #: code:addons/addons/pos_barcode_tare/models/barcode_rule.py:13 @@ -89,25 +94,78 @@ msgstr "Tare" #. module: pos_barcode_tare #. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:90 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:90 +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:164 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:164 +#, python-format +msgid "The scale sent a measure in %s unit. This unit of measure (UOM) in not found in the point of sale. You may need to create a new UOM named %s. The UOM name is case sensitive." +msgstr "La balance à envoyé une mesure en %s. Cette unité de mesure (UOM) n'existe pas. Vous devez probablement créer une UOM nommée %s. Le nom de l'UOM est sensible à la casse." + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:288 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:288 +#, python-format +msgid "The tare (%s) is already set for the product \"%s\". We can not re-apply a tare to this product." +msgstr "La tare (%s) est déjà mesurée pour le produit \"%s\". Nous ne pouvons plus appliquer de tare à ce produit." + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:319 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:319 #, python-format -msgid "The calculated weight is negative. Did you scan the correct tare label?" -msgstr "Le poids net calculé est négatif. Avez vous scanné la bonne étiquette de tare?" +msgid "The tare weight is %s %s, it's greater or equal to the product weight %s. We can not apply this tare." +msgstr "Le poids de la tare est de %s %s, c'est plus que le poids du produit %s. Nous ne pouvons pas appliquer cette tare." #. module: pos_barcode_tare #. openerp-web #: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:74 #: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:74 #, python-format -msgid "You scanned a tare barcode. The tare should apply to \"%s %s of %s\". We do not know how to convert kg to %s. We can not apply the tare to this product." -msgstr "Vous avez scanné une étiquette de tare. La tare devrait être appliquée à \"%s %s de %s\". Nous ne savons pas convertir des kg en %s. La tare ne peut pas être appliqué à ce produit." +msgid "We can not apply this tare barcode." +msgstr "Impossible d'appliquer cette étiquette de tare." + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:33 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:33 +#, python-format +msgid "We can not cast a weight in %s into %s." +msgstr "Nous ne pouvons pas convertir un poids en %s en %s." + +#. module: pos_barcode_tare +#: model:product.uom.categ,name:pos_barcode_tare.product_uom_categ_kgm +msgid "Weight" +msgstr "Poids" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:69 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:69 +#, python-format +msgid "With a" +msgstr "Avec un(e)" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:61 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:61 +#, python-format +msgid "at" +msgstr "à" #. module: pos_barcode_tare #: model:ir.model,name:pos_barcode_tare.model_barcode_rule msgid "barcode.rule" msgstr "barcode.rule" +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:71 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:71 +#, python-format +msgid "discount" +msgstr "remise" + #. module: pos_barcode_tare #. openerp-web #: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 @@ -124,7 +182,9 @@ msgstr "pos.config" #. module: pos_barcode_tare #. openerp-web #: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:78 #: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:78 #, python-format msgid "tare =" msgstr "tare =" diff --git a/pos_barcode_tare/i18n/pos_barcode_tare.pot b/pos_barcode_tare/i18n/pos_barcode_tare.pot index 71b3e135..b76f9c1f 100644 --- a/pos_barcode_tare/i18n/pos_barcode_tare.pot +++ b/pos_barcode_tare/i18n/pos_barcode_tare.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-05 18:22+0000\n" -"PO-Revision-Date: 2020-02-05 18:22+0000\n" +"POT-Creation-Date: 2020-02-14 06:05+0000\n" +"PO-Revision-Date: 2020-02-14 06:05+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -24,24 +24,29 @@ msgid "Back" msgstr "" #. module: pos_barcode_tare -#: model:ir.ui.view,arch_db:pos_barcode_tare.view_pos_config_form -msgid "Loose good options" +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:130 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:130 +#, python-format +msgid "Failed to read weight from scale." msgstr "" #. module: pos_barcode_tare -#. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:72 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:72 -#, python-format -msgid "Mismatch in units of measure" +#: model:product.uom,name:pos_barcode_tare.product_uom_kgm_dbg +msgid "Kg" +msgstr "" + +#. module: pos_barcode_tare +#: model:ir.ui.view,arch_db:pos_barcode_tare.view_pos_config_form +msgid "Loose good options" msgstr "" #. module: pos_barcode_tare #. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:89 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:89 +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:196 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:196 #, python-format -msgid "Negative weight" +msgid "Maximum tare weight is 99.999kg" msgstr "" #. module: pos_barcode_tare @@ -89,10 +94,26 @@ msgstr "" #. module: pos_barcode_tare #. openerp-web -#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:90 -#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:90 +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:164 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:164 #, python-format -msgid "The calculated weight is negative. Did you scan the correct tare label?" +msgid "The scale sent a measure in %s unit. This unit of measure (UOM) in not found in the point of sale. You may need to create a new UOM named %s. The UOM name is case sensitive." +msgstr "" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:288 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:288 +#, python-format +msgid "The tare (%s) is already set for the product \"%s\". We can not re-apply a tare to this product." +msgstr "" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:319 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:319 +#, python-format +msgid "The tare weight is %s %s this is greater or equal to the product weight %s. We can not apply this tare." msgstr "" #. module: pos_barcode_tare @@ -100,7 +121,36 @@ msgstr "" #: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:74 #: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:74 #, python-format -msgid "You scanned a tare barcode. The tare should apply to \"%s %s of %s\". We do not know how to convert kg to %s. We can not apply the tare to this product." +msgid "We can not apply this tare barcode." +msgstr "" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:33 +#: code:addons/pos_barcode_tare/static/src/js/pos_barcode_tare.js:33 +#, python-format +msgid "We can not cast a weight in %s into %s." +msgstr "" + +#. module: pos_barcode_tare +#: model:product.uom.categ,name:pos_barcode_tare.product_uom_categ_kgm +msgid "Weight" +msgstr "" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:69 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:69 +#, python-format +msgid "With a" +msgstr "" + +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:61 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:61 +#, python-format +msgid "at" msgstr "" #. module: pos_barcode_tare @@ -108,6 +158,14 @@ msgstr "" msgid "barcode.rule" msgstr "" +#. module: pos_barcode_tare +#. openerp-web +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:71 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:71 +#, python-format +msgid "discount" +msgstr "" + #. module: pos_barcode_tare #. openerp-web #: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 @@ -124,7 +182,9 @@ msgstr "" #. module: pos_barcode_tare #. openerp-web #: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 +#: code:addons/addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:78 #: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:32 +#: code:addons/pos_barcode_tare/static/src/xml/pos_barcode_tare.xml:78 #, python-format msgid "tare =" msgstr "" diff --git a/pos_barcode_tare/static/src/js/pos_barcode_tare.js b/pos_barcode_tare/static/src/js/pos_barcode_tare.js index b383f351..927a86cd 100644 --- a/pos_barcode_tare/static/src/js/pos_barcode_tare.js +++ b/pos_barcode_tare/static/src/js/pos_barcode_tare.js @@ -124,7 +124,13 @@ odoo.define('pos_barcode_tare.screens', function (require) { var self = this; queue.schedule(function () { return self.pos.proxy.scale_read().then(function (weight) { - self.set_weight(weight); + try { + self.set_weight(weight); + } catch (error) { + var title = _t("Failed to read weight from scale."); + var popup = {title: title, body: error.message}; + self.gui.show_popup('error', popup); + } }); }, {duration:150, repeat: true}); // Shows a barcode whose weight might be zero, but this is preferred @@ -152,6 +158,16 @@ odoo.define('pos_barcode_tare.screens', function (require) { set_weight: function (scale_measure) { var weight = scale_measure.weight; var unit = get_unit(this.pos, scale_measure.unit); + + if (typeof unit === 'undefined') { + throw new Error(_.str.sprintf( + _t("The scale sent a measure in %s unit. This unit of "+ + "measure (UOM) in not found in the point of sale. You " + + "may need to create a new UOM named %s. The UOM name is "+ + "case sensitive."), scale_measure.unit, + scale_measure.unit)); + } + if (weight > 0) { this.weight_in_kg = convert_mass(weight, unit, this.kg_unit); this.render_receipt(); @@ -174,7 +190,12 @@ odoo.define('pos_barcode_tare.screens', function (require) { // is a checksum, here symbolized by x. var padding_size = 5; var void_product_id = '0'.repeat(padding_size); - var weight_in_gram = weight * 10e2; + var weight_in_gram = weight * 1e3; + + if (weight_in_gram >= Math.pow(10, padding_size)) { + throw new RangeError(_t("Maximum tare weight is 99.999kg")); + } + // Weight has to be padded with zeros. var weight_with_padding = '0'.repeat(padding_size) + weight_in_gram; var padded_weight = weight_with_padding.substr( @@ -295,7 +316,7 @@ odoo.define('pos_barcode_tare.screens', function (require) { // This method fails when the net weight is negative. if (net_quantity <= 0) { throw new RangeError(_.str.sprintf( - _t("The tare weight is %s %s this is greater or equal to " + + _t("The tare weight is %s %s, it's greater or equal to " + "the product weight %s. We can not apply this tare."), tare_in_product_uom_string, unit.name, this.get_quantity_str_with_unit()));