From 41af109f4eae20bbef78d9930e17d30309f82382 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 14 Jun 2015 00:19:53 +0200 Subject: [PATCH] Make some messages of customer display configurable JS code cleanup: harmonize identation --- .../customer_display_view.xml | 8 ++ pos_customer_display/i18n/fr.po | 81 ++++++++++++----- .../i18n/pos_customer_display.pot | 71 +++++++++++---- pos_customer_display/pos_customer_display.py | 45 +++++++++- .../static/src/js/customer_display.js | 86 +++++++++++-------- 5 files changed, 215 insertions(+), 76 deletions(-) diff --git a/pos_customer_display/customer_display_view.xml b/pos_customer_display/customer_display_view.xml index 80b238a6..b259f7be 100644 --- a/pos_customer_display/customer_display_view.xml +++ b/pos_customer_display/customer_display_view.xml @@ -10,6 +10,14 @@ + + + + + + + + diff --git a/pos_customer_display/i18n/fr.po b/pos_customer_display/i18n/fr.po index 06daa1f8..d937f091 100644 --- a/pos_customer_display/i18n/fr.po +++ b/pos_customer_display/i18n/fr.po @@ -6,30 +6,41 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-05-16 23:24+0000\n" -"PO-Revision-Date: 2015-05-16 23:24+0000\n" -"Last-Translator: Alexis de Lattre \n" +"POT-Creation-Date: 2015-06-13 22:12+0000\n" +"PO-Revision-Date: 2015-06-13 22:12+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_customer_display +#: help:pos.config,customer_display_msg_next_l2:0 +msgid "Bottom line of the message on the customer display which is displayed after starting POS and also after validation of an order" +msgstr "Ligne du bas du message de l'afficheur client qui est affiché après le démarrage de la caisse et également après validation d'une commande client" + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_closed_l2:0 +msgid "Bottom line of the message on the customer display which is displayed when POS is closed" +msgstr "Ligne du bas du message de l'afficheur client qui est affiché quand la caisse est fermée" + #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:58 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:56 #, python-format msgid "Cancel Payment" msgstr "Paiement annulé" #. module: pos_customer_display +#: view:pos.config:pos_customer_display.view_pos_config_form2 #: field:pos.config,iface_customer_display:0 msgid "Customer Display" msgstr "Afficheur client" #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:42 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:41 #, python-format msgid "Delete Item" msgstr "Article supprimé" @@ -53,40 +64,68 @@ msgstr "Longueur des lignes de l'afficheur client: nombre de caractères" #. module: pos_customer_display #: field:pos.config,customer_display_line_length:0 -msgid "Line Length" -msgstr "Longueur des lignes" +msgid "Line Length of the Customer Display" +msgstr "Longueur de ligne de l'afficheur client" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:71 +#: code:addons/pos_customer_display/pos_customer_display.py:63 +#: field:pos.config,customer_display_msg_next_l2:0 #, python-format -msgid "Next Customer" -msgstr "Client suivant" +msgid "Next Customer (bottom line)" +msgstr "Client suivant (ligne du bas)" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:83 +#: code:addons/pos_customer_display/pos_customer_display.py:62 +#: field:pos.config,customer_display_msg_next_l1:0 #, python-format -msgid "Point of Sale Closed" -msgstr "Caisse fermée" +msgid "Next Customer (top line)" +msgstr "Client suivant (ligne du haut)" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:77 +#: code:addons/pos_customer_display/pos_customer_display.py:66 +#: field:pos.config,customer_display_msg_closed_l2:0 +#, python-format +msgid "POS Closed (bottom line)" +msgstr "Caisse fermée (ligne du bas)" + +#. module: pos_customer_display +#: code:addons/pos_customer_display/pos_customer_display.py:65 +#: field:pos.config,customer_display_msg_closed_l1:0 #, python-format -msgid "Point of Sale Open" -msgstr "Caisse ouverte" +msgid "POS Closed (top line)" +msgstr "Caisse fermée (ligne du haut)" + +#. module: pos_customer_display +#: view:pos.config:pos_customer_display.view_pos_config_form2 +msgid "Receipt" +msgstr "Reçu" #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:50 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:48 #, python-format msgid "TOTAL: " msgstr "TOTAL : " +#. module: pos_customer_display +#: code:addons/pos_customer_display/pos_customer_display.py:72 +#, python-format +msgid "The message for customer display '%s' is too long: it has %d chars whereas the maximum is %d chars." +msgstr "Le message de l'afficheur client '%s' est trop long : il contient %d caractères alors que le maximum est de %d caractères." + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_next_l1:0 +msgid "Top line of the message on the customer display which is displayed after starting POS and also after validation of an order" +msgstr "Ligne du haut du message de l'afficheur client qui est affiché après le démarrage de la caisse et également après validation d'une commande client" + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_closed_l1:0 +msgid "Top line of the message on the customer display which is displayed when POS is closed" +msgstr "Ligne du haut du message de l'afficheur client qui est affiché quand la caisse est fermée" + #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:65 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:63 #, python-format msgid "Your Change:" msgstr "Monnaie à rendre :" diff --git a/pos_customer_display/i18n/pos_customer_display.pot b/pos_customer_display/i18n/pos_customer_display.pot index 6ff26e33..7aa56659 100644 --- a/pos_customer_display/i18n/pos_customer_display.pot +++ b/pos_customer_display/i18n/pos_customer_display.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-05-16 23:24+0000\n" -"PO-Revision-Date: 2015-05-16 23:24+0000\n" +"POT-Creation-Date: 2015-06-13 22:11+0000\n" +"PO-Revision-Date: 2015-06-13 22:11+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,21 +15,32 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_next_l2:0 +msgid "Bottom line of the message on the customer display which is displayed after starting POS and also after validation of an order" +msgstr "" + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_closed_l2:0 +msgid "Bottom line of the message on the customer display which is displayed when POS is closed" +msgstr "" + #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:58 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:56 #, python-format msgid "Cancel Payment" msgstr "" #. module: pos_customer_display +#: view:pos.config:pos_customer_display.view_pos_config_form2 #: field:pos.config,iface_customer_display:0 msgid "Customer Display" msgstr "" #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:42 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:41 #, python-format msgid "Delete Item" msgstr "" @@ -53,40 +64,68 @@ msgstr "" #. module: pos_customer_display #: field:pos.config,customer_display_line_length:0 -msgid "Line Length" +msgid "Line Length of the Customer Display" msgstr "" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:71 +#: code:addons/pos_customer_display/pos_customer_display.py:63 +#: field:pos.config,customer_display_msg_next_l2:0 #, python-format -msgid "Next Customer" +msgid "Next Customer (bottom line)" msgstr "" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:83 +#: code:addons/pos_customer_display/pos_customer_display.py:62 +#: field:pos.config,customer_display_msg_next_l1:0 #, python-format -msgid "Point of Sale Closed" +msgid "Next Customer (top line)" msgstr "" #. module: pos_customer_display -#. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:77 +#: code:addons/pos_customer_display/pos_customer_display.py:66 +#: field:pos.config,customer_display_msg_closed_l2:0 +#, python-format +msgid "POS Closed (bottom line)" +msgstr "" + +#. module: pos_customer_display +#: code:addons/pos_customer_display/pos_customer_display.py:65 +#: field:pos.config,customer_display_msg_closed_l1:0 #, python-format -msgid "Point of Sale Open" +msgid "POS Closed (top line)" +msgstr "" + +#. module: pos_customer_display +#: view:pos.config:pos_customer_display.view_pos_config_form2 +msgid "Receipt" msgstr "" #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:50 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:48 #, python-format msgid "TOTAL: " msgstr "" +#. module: pos_customer_display +#: code:addons/pos_customer_display/pos_customer_display.py:72 +#, python-format +msgid "The message for customer display '%s' is too long: it has %d chars whereas the maximum is %d chars." +msgstr "" + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_next_l1:0 +msgid "Top line of the message on the customer display which is displayed after starting POS and also after validation of an order" +msgstr "" + +#. module: pos_customer_display +#: help:pos.config,customer_display_msg_closed_l1:0 +msgid "Top line of the message on the customer display which is displayed when POS is closed" +msgstr "" + #. module: pos_customer_display #. openerp-web -#: code:addons/pos_customer_display/static/src/js/customer_display.js:65 +#: code:addons/pos_customer_display/static/src/js/customer_display.js:63 #, python-format msgid "Your Change:" msgstr "" diff --git a/pos_customer_display/pos_customer_display.py b/pos_customer_display/pos_customer_display.py index 060e7881..9dbae58d 100644 --- a/pos_customer_display/pos_customer_display.py +++ b/pos_customer_display/pos_customer_display.py @@ -21,7 +21,8 @@ # ############################################################################## -from openerp import models, fields +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError class PosConfig(models.Model): @@ -30,5 +31,45 @@ class PosConfig(models.Model): iface_customer_display = fields.Boolean( string='Customer Display', help="Display data on the customer display") customer_display_line_length = fields.Integer( - string='Line Length', default=20, + string='Line Length of the Customer Display', default=20, help="Length of the LEDs lines of the customer display") + customer_display_msg_next_l1 = fields.Char( + string="Next Customer (top line)", default="Welcome!", + help="Top line of the message on the customer display which is " + "displayed after starting POS and also after validation of an order") + customer_display_msg_next_l2 = fields.Char( + string="Next Customer (bottom line)", default="Point of Sale Open", + help="Bottom line of the message on the customer display which is " + "displayed after starting POS and also after validation of an order") + customer_display_msg_closed_l1 = fields.Char( + string="POS Closed (top line)", default="Point of Sale Closed", + help="Top line of the message on the customer display which " + "is displayed when POS is closed") + customer_display_msg_closed_l2 = fields.Char( + string="POS Closed (bottom line)", default="See you soon!", + help="Bottom line of the message on the customer display which " + "is displayed when POS is closed") + + @api.one + @api.constrains( + 'customer_display_line_length', + 'customer_display_msg_next_l1', 'customer_display_msg_next_l2', + 'customer_display_msg_closed_l1', 'customer_display_msg_closed_l2') + def _check_customer_display_length(self): + if self.customer_display_line_length: + maxsize = self.customer_display_line_length + to_check = { + _('Next Customer (top line)'): self.customer_display_msg_next_l1, + _('Next Customer (bottom line)'): + self.customer_display_msg_next_l2, + _('POS Closed (top line)'): self.customer_display_msg_closed_l1, + _('POS Closed (bottom line)'): + self.customer_display_msg_closed_l2, + } + for field, msg in to_check.iteritems(): + if msg and len(msg) > maxsize: + raise ValidationError( + _("The message for customer display '%s' is too " + "long: it has %d chars whereas the maximum " + "is %d chars.") + % (field, len(msg), maxsize)) diff --git a/pos_customer_display/static/src/js/customer_display.js b/pos_customer_display/static/src/js/customer_display.js index 380112c4..2f245d4f 100755 --- a/pos_customer_display/static/src/js/customer_display.js +++ b/pos_customer_display/static/src/js/customer_display.js @@ -66,20 +66,20 @@ openerp.pos_customer_display = function(instance){ } else if (type == 'pushOrder') { var lines_to_send = new Array( - this.proxy.align_center(_t("Next Customer"), line_length), - this.proxy.align_left(' ', line_length) + this.proxy.align_center(this.config.customer_display_msg_next_l1, line_length), + this.proxy.align_center(this.config.customer_display_msg_next_l2, line_length) ); } else if (type == 'openPOS') { var lines_to_send = new Array( - this.proxy.align_center(_t("Point of Sale Open"), line_length), - this.proxy.align_left(' ', line_length) + this.proxy.align_center(this.config.customer_display_msg_next_l1, line_length), + this.proxy.align_center(this.config.customer_display_msg_next_l2, line_length) ); } else if (type = 'closePOS') { var lines_to_send = new Array( - this.proxy.align_center(_t("Point of Sale Closed"), line_length), - this.proxy.align_left(' ', line_length) + this.proxy.align_center(this.config.customer_display_msg_closed_l1, line_length), + this.proxy.align_center(this.config.customer_display_msg_closed_l2, line_length) ); } else { console.warn('Unknown message type'); @@ -114,54 +114,66 @@ openerp.pos_customer_display = function(instance){ align_left: function(string, length){ if (string) { - if (string.length > length) - { - return string.substring(0,length); - } - else if (string.length < length) - { + if (string.length > length) + { + string = string.substring(0,length); + } + else if (string.length < length) + { while(string.length < length) - string = string + ' '; - return string; - } + string = string + ' '; + } + } + else { + string = ' ' + while(string.length < length) + string = ' ' + string; } return string; }, - align_right: function(string, length){ + align_right: function(string, length){ if (string) { if (string.length > length) - { - return string.substring(0,length); - } - else if (string.length < length) - { + { + string = string.substring(0,length); + } + else if (string.length < length) + { while(string.length < length) - string = ' ' + string; - return string; + string = ' ' + string; } - } - return string; - }, + } + else { + string = ' ' + while(string.length < length) + string = ' ' + string; + } + return string; + }, - align_center: function(string, length){ + align_center: function(string, length){ if (string) { if (string.length > length) { - return string.substring(0, length); + string = string.substring(0, length); } else if (string.length < length) { - ini = (length - string.length) / 2; - while(string.length < length - ini) - string = ' ' + string; - while(string.length < length) - string = string + ' '; - return string; + ini = (length - string.length) / 2; + while(string.length < length - ini) + string = ' ' + string; + while(string.length < length) + string = string + ' '; } - } - return string; - }, + } + else { + string = ' ' + while(string.length < length) + string = ' ' + string; + } + return string; + }, }); var OrderSuper = module.Order;