Commit e46288b7 by François C.

Merge branch '2245-made-paper-meal-vouhcer-usable-once' into 'dev_cooperatic'

display a popup if the meal voucher was already scan on this order

See merge request !27
parents 2d9688f3 ae3e4f87
...@@ -322,6 +322,25 @@ msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible ...@@ -322,6 +322,25 @@ msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible
#. module: pos_meal_voucher #. module: pos_meal_voucher
#. openerp-web #. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "Meal Voucher already used"
msgstr "Ticket restaurant déjà scanné"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "The paper meal voucher "
msgstr "Le ticket restaurant "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid " was already used"
msgstr " a déjà été scanné"
#: code:addons/pos_meal_voucher/static/src/js/screens.js:196 #: code:addons/pos_meal_voucher/static/src/js/screens.js:196
#, python-format #, python-format
msgid "Meal Voucher ticket" msgid "Meal Voucher ticket"
...@@ -333,3 +352,4 @@ msgstr "Chèque restaurant" ...@@ -333,3 +352,4 @@ msgstr "Chèque restaurant"
#, python-format #, python-format
msgid "To add a meal voucher ticket close this window and scan the ticket. If the ticket can't be read please enter the code" msgid "To add a meal voucher ticket close this window and scan the ticket. If the ticket can't be read please enter the code"
msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et scanner le chèque. Si le chèque est illisible veuillez rentrer le code à la main." msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et scanner le chèque. Si le chèque est illisible veuillez rentrer le code à la main."
...@@ -17,6 +17,14 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -17,6 +17,14 @@ odoo.define("pos_meal_voucher.models", function (require) {
var OrderSuper = models.Order.prototype; var OrderSuper = models.Order.prototype;
var Order = models.Order.extend({ var Order = models.Order.extend({
paper_meal_vouche_number_already_used: function(meal_voucher_number){
for(const paiementLine of this.get_paymentlines()){
if(paiementLine.statement_note == meal_voucher_number) return true
}
return false;
},
get_total_meal_voucher_eligible: function() { get_total_meal_voucher_eligible: function() {
return round_pr(this.orderlines.reduce((function(sum, orderLine) { return round_pr(this.orderlines.reduce((function(sum, orderLine) {
if (orderLine.product.meal_voucher_ok && orderLine.get_price_with_tax() > 0){ if (orderLine.product.meal_voucher_ok && orderLine.get_price_with_tax() > 0){
......
...@@ -14,6 +14,8 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -14,6 +14,8 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.ScreenWidget.include({ screens.ScreenWidget.include({
barcode_meal_voucher_payment_action: function (code) { barcode_meal_voucher_payment_action: function (code) {
var oder = this.pos.get_order();
if(!oder.paper_meal_vouche_number_already_used(code.code)){
// Display the payment screen, if it is not the current one. // Display the payment screen, if it is not the current one.
if (this.pos.gui.current_screen.template !== "PaymentScreenWidget"){ if (this.pos.gui.current_screen.template !== "PaymentScreenWidget"){
this.gui.show_screen("payment"); this.gui.show_screen("payment");
...@@ -41,6 +43,17 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -41,6 +43,17 @@ odoo.define("pos_meal_voucher.screens", function (require) {
paymentScreen.order_changes(); paymentScreen.order_changes();
paymentScreen.render_paymentlines(); paymentScreen.render_paymentlines();
paymentScreen.$(".paymentline.selected .edit").text(paymentScreen.format_currency_no_symbol(amount)); paymentScreen.$(".paymentline.selected .edit").text(paymentScreen.format_currency_no_symbol(amount));
}else{
this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount already used"),
'body': _t("The paper meal voucher ") +
code.code + _t(" was already used"),
});
}
}, },
// Setup the callback action for the "meal_voucher_payment" barcodes. // Setup the callback action for the "meal_voucher_payment" barcodes.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment