Commit 89b11cb3 by Etienne Freiss

Merge branch '2341-display-meal-voucher-only-on-pos-activated' into 'dev_cooperatic'

hide meal voucher if it's not activated

See merge request !28
parents bbde8038 469eaca5
......@@ -67,9 +67,28 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.OrderWidget.include({
//check if POS if configured to accept payment in meal voucher
meal_voucher_activated: function() {
var is_meal_voucher_method = this.pos.cashregisters.map(function(cash_register) {
if (cash_register.journal.meal_voucher_type === "paper" || cash_register.journal.meal_voucher_type === "dematerialized") {
return true
}
})
return is_meal_voucher_method.includes(true);
},
update_summary: function () {
this._super.apply(this, arguments);
var order = this.pos.get_order();
if (!this.meal_voucher_activated()) {
const meal_voucher_summary = this.el.querySelector(".summary .meal-voucher");
if (meal_voucher_summary != null) {
meal_voucher_summary.style.display = 'none';
}
// this.el.querySelector(".summary .meal-voucher").style.display = 'none';
return;
}
if (!order.get_orderlines().length) {
return;
}
......@@ -80,6 +99,15 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.PaymentScreenWidget.include({
//check if POS if configured to accept payment in meal voucher
meal_voucher_activated: function() {
var is_meal_voucher_method = this.pos.cashregisters.map(function(cash_register) {
if (cash_register.journal.meal_voucher_type === "paper" || cash_register.journal.meal_voucher_type === "dematerialized") {
return true
}
})
return is_meal_voucher_method.includes(true);
},
// odoo/addons/point_of_sale/static/src/js/screens.js
// We need to change the default behaviour of locking input with
......@@ -296,6 +324,7 @@ odoo.define("pos_meal_voucher.screens", function (require) {
if (!order) {
return;
}
// Update meal voucher summary
var total_eligible = order.get_total_meal_voucher_eligible();
this.el.querySelector("#meal-voucher-eligible-amount").textContent = this.format_currency(total_eligible);
......@@ -319,6 +348,10 @@ odoo.define("pos_meal_voucher.screens", function (require) {
this.$("#meal-voucher-max-warning").addClass("oe_hidden");
}
if (!this.meal_voucher_activated()) {
this.$(".meal-voucher-summary").addClass("oe_hidden");
}
},
order_is_valid: function(force_validation) {
......
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