From 3d36ee40c2bc88cea257ba7a60e4876bd12cc66b Mon Sep 17 00:00:00 2001 From: Joseph Caburnay Date: Fri, 26 Feb 2021 15:25:35 +0000 Subject: [PATCH] [FIX] point_of_sale: translation issue in the ticket screen The terms in the search bar of the ticket screen are not translated. This commit fixes this issue by passing the translated form of the terms to the search bar component. closes odoo/odoo#66959 X-original-commit: 11d7daa481c05e56228e5b1bbf1ed1c0fe57e774 Signed-off-by: Martin Trigaux (mat) --- addons/point_of_sale/i18n/point_of_sale.pot | 40 +++++++++++++++++++ .../static/src/js/Misc/SearchBar.js | 2 +- .../js/Screens/TicketScreen/TicketScreen.js | 38 +++++++++++++----- .../xml/Screens/TicketScreen/TicketScreen.xml | 3 +- addons/pos_restaurant/i18n/pos_restaurant.pot | 14 +++++++ .../static/src/js/Screens/TicketScreen.js | 18 ++++++--- 6 files changed, 99 insertions(+), 16 deletions(-) diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 5dd9fe17f80..f568e2e18f8 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -383,6 +383,13 @@ msgstr "" msgid "All" msgstr "" +#. module: point_of_sale +#. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#, python-format +msgid "All Tickets" +msgstr "" + #. module: point_of_sale #: code:addons/point_of_sale/models/pos_config.py:0 #, python-format @@ -715,6 +722,7 @@ msgstr "" #. module: point_of_sale #. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 #: code:addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml:0 #: model:ir.model.fields,field_description:point_of_sale.field_pos_payment__cardholder_name #, python-format @@ -1213,6 +1221,7 @@ msgstr "" #. module: point_of_sale #. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 #: code:addons/point_of_sale/static/src/xml/Screens/OrderManagementScreen/OrderList.xml:0 #: code:addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml:0 #: code:addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml:0 @@ -1258,6 +1267,7 @@ msgstr "" #. module: point_of_sale #. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 #: code:addons/point_of_sale/static/src/xml/Screens/OrderManagementScreen/OrderList.xml:0 #: code:addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml:0 #: model:ir.model.fields,field_description:point_of_sale.field_pos_order__date_order @@ -2640,6 +2650,13 @@ msgstr "" msgid "Ok" msgstr "" +#. module: point_of_sale +#. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#, python-format +msgid "Ongoing" +msgstr "" + #. module: point_of_sale #: model:ir.model.fields,field_description:point_of_sale.field_pos_config__only_round_cash_method msgid "Only apply rounding on cash" @@ -2936,6 +2953,7 @@ msgstr "" #. module: point_of_sale #. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 #: code:addons/point_of_sale/static/src/xml/Screens/PaymentScreen/PaymentScreen.xml:0 #: code:addons/point_of_sale/static/src/xml/Screens/ProductScreen/ActionpadWidget.xml:0 #: code:addons/point_of_sale/wizard/pos_payment.py:0 @@ -3687,6 +3705,13 @@ msgstr "" msgid "Ready to launch your point of sale?" msgstr "" +#. module: point_of_sale +#. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 +#, python-format +msgid "Receipt" +msgstr "" + #. module: point_of_sale #: code:addons/point_of_sale/models/pos_order.py:0 #, python-format @@ -3705,6 +3730,7 @@ msgstr "" #. module: point_of_sale #. openerp-web +#: code:addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js:0 #: code:addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml:0 #: model:ir.model.fields,field_description:point_of_sale.field_pos_order__pos_reference #, python-format @@ -3974,6 +4000,20 @@ msgstr "" msgid "Search Sales Order" msgstr "" +#. module: point_of_sale +#. openerp-web +#: code:addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml:0 +#, python-format +msgid "Search Tickets..." +msgstr "" + +#. module: point_of_sale +#. openerp-web +#: code:addons/point_of_sale/static/src/js/Misc/SearchBar.js:0 +#, python-format +msgid "Select" +msgstr "" + #. module: point_of_sale #. openerp-web #: code:addons/point_of_sale/static/src/js/Screens/ProductScreen/ControlButtons/SetFiscalPositionButton.js:0 diff --git a/addons/point_of_sale/static/src/js/Misc/SearchBar.js b/addons/point_of_sale/static/src/js/Misc/SearchBar.js index d9bcfe879b1..e9f56feaf81 100644 --- a/addons/point_of_sale/static/src/js/Misc/SearchBar.js +++ b/addons/point_of_sale/static/src/js/Misc/SearchBar.js @@ -37,7 +37,7 @@ odoo.define('point_of_sale.SearchBar', function (require) { selectedFieldId: this.config.searchFields.length ? 0 : null, showSearchFields: false, showFilterOptions: false, - selectedFilter: this.config.filter.options[0] || 'Select', + selectedFilter: this.config.filter.options[0] || this.env._t('Select'), }); useExternalListener(window, 'click', this._hideOptions); } diff --git a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js index 38d4cd6efb4..dd7adce4e07 100644 --- a/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js +++ b/addons/point_of_sale/static/src/js/Screens/TicketScreen/TicketScreen.js @@ -45,8 +45,9 @@ odoo.define('point_of_sale.TicketScreen', function (require) { return this.env.pos.get_order_list(); } get filteredOrderList() { + const { AllTickets } = this.getOrderStates(); const filterCheck = (order) => { - if (this.filter && this.filter !== 'All Tickets') { + if (this.filter && this.filter !== AllTickets) { const screen = order.get_screen_data(); return this.filter === this.constants.screenToStatusMap[screen.name]; } @@ -131,7 +132,8 @@ odoo.define('point_of_sale.TicketScreen', function (require) { }; } get filterOptions() { - return ['All Tickets', 'Ongoing', 'Payment', 'Receipt']; + const { AllTickets, Ongoing, Payment, Receipt } = this.getOrderStates(); + return [AllTickets, Ongoing, Payment, Receipt]; } /** * An object with keys containing the search field names which map to functions. @@ -158,14 +160,15 @@ odoo.define('point_of_sale.TicketScreen', function (require) { * @returns Record string> */ get _searchFields() { + const { ReceiptNumber, Date, Customer, CardholderName } = this.getSearchFieldNames(); var fields = { - 'Receipt Number': (order) => order.name, - Date: (order) => moment(order.creation_date).format('YYYY-MM-DD hh:mm A'), - Customer: (order) => order.get_client_name(), + [ReceiptNumber]: (order) => order.name, + [Date]: (order) => moment(order.creation_date).format('YYYY-MM-DD hh:mm A'), + [Customer]: (order) => order.get_client_name(), }; if (this.showCardholderName()) { - fields['Cardholder Name'] = (order) => order.get_cardholder_name(); + fields[CardholderName] = (order) => order.get_cardholder_name(); } return fields; @@ -174,10 +177,11 @@ odoo.define('point_of_sale.TicketScreen', function (require) { * Maps the order screen params to order status. */ get _screenToStatusMap() { + const { Ongoing, Payment, Receipt } = this.getOrderStates(); return { - ProductScreen: 'Ongoing', - PaymentScreen: 'Payment', - ReceiptScreen: 'Receipt', + ProductScreen: Ongoing, + PaymentScreen: Payment, + ReceiptScreen: Receipt, }; } _initializeSearchFieldConstants() { @@ -187,6 +191,22 @@ odoo.define('point_of_sale.TicketScreen', function (require) { screenToStatusMap: this._screenToStatusMap, }); } + getOrderStates() { + return { + AllTickets: this.env._t('All Tickets'), + Ongoing: this.env._t('Ongoing'), + Payment: this.env._t('Payment'), + Receipt: this.env._t('Receipt'), + }; + } + getSearchFieldNames() { + return { + ReceiptNumber: this.env._t('Receipt Number'), + Date: this.env._t('Date'), + Customer: this.env._t('Customer'), + CardholderName: this.env._t('Cardholder Name'), + }; + } } TicketScreen.template = 'TicketScreen'; diff --git a/addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml b/addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml index 638db944fba..40bfc501839 100644 --- a/addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml +++ b/addons/point_of_sale/static/src/xml/Screens/TicketScreen/TicketScreen.xml @@ -9,7 +9,8 @@ - + Search Tickets... +
diff --git a/addons/pos_restaurant/i18n/pos_restaurant.pot b/addons/pos_restaurant/i18n/pos_restaurant.pot index 40216fce98c..f3f96a26a4e 100644 --- a/addons/pos_restaurant/i18n/pos_restaurant.pot +++ b/addons/pos_restaurant/i18n/pos_restaurant.pot @@ -585,6 +585,13 @@ msgstr "" msgid "Ok" msgstr "" +#. module: pos_restaurant +#. openerp-web +#: code:addons/pos_restaurant/static/src/js/Screens/TicketScreen.js:0 +#, python-format +msgid "Open" +msgstr "" + #. module: pos_restaurant #. openerp-web #: code:addons/pos_restaurant/static/src/xml/Screens/FloorScreen/EditBar.xml:0 @@ -1035,6 +1042,13 @@ msgstr "" msgid "Tip:" msgstr "" +#. module: pos_restaurant +#. openerp-web +#: code:addons/pos_restaurant/static/src/js/Screens/TicketScreen.js:0 +#, python-format +msgid "Tipping" +msgstr "" + #. module: pos_restaurant #. openerp-web #: code:addons/pos_restaurant/static/src/xml/TipReceipt.xml:0 diff --git a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js index c2bb21333a9..cbea3d88868 100644 --- a/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js +++ b/addons/pos_restaurant/static/src/js/Screens/TicketScreen.js @@ -20,17 +20,19 @@ odoo.define('pos_restaurant.TicketScreen', function (require) { } } get filterOptions() { + const { Payment, Open, Tipping } = this.getOrderStates(); var filterOptions = super.filterOptions; if (this.env.pos.config.set_tip_after_payment) { - var idx = filterOptions.indexOf('Payment'); - filterOptions[idx] = 'Open'; + var idx = filterOptions.indexOf(Payment); + filterOptions[idx] = Open; } - return [...filterOptions, 'Tipping']; + return [...filterOptions, Tipping]; } get _screenToStatusMap() { + const { Open, Tipping } = this.getOrderStates(); return Object.assign(super._screenToStatusMap, { - PaymentScreen: this.env.pos.config.set_tip_after_payment ? 'Open' : super._screenToStatusMap.PaymentScreen, - TipScreen: 'Tipping', + PaymentScreen: this.env.pos.config.set_tip_after_payment ? Open : super._screenToStatusMap.PaymentScreen, + TipScreen: Tipping, }); } getTable(order) { @@ -116,6 +118,12 @@ odoo.define('pos_restaurant.TicketScreen', function (require) { args: [serverId], }); } + getOrderStates() { + return Object.assign(super.getOrderStates(), { + Tipping: this.env._t('Tipping'), + Open: this.env._t('Open'), + }); + } }; Registries.Component.extend(TicketScreen, PosResTicketScreen);