Commit 07d82be9 by Etienne Freiss

Merge branch '2613-fix-pos-ticket-with-meal-vouchers' into 'dev_cooperatic'

2613-fix-pos-ticket-with-meal-vouchers

See merge request !34
parents 5743b9cb 28ea6dd1
...@@ -355,21 +355,21 @@ msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et sca ...@@ -355,21 +355,21 @@ msgstr "Pour ajouter un chèque restaurant merci de fermer cette fenêtre et sca
#. module: pos_meal_voucher #. module: pos_meal_voucher
#. openerp-web #. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:96 #: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:101
#, python-format #, python-format
msgid "Eligible subtotal for meal vouchers:" msgid "Eligible subtotal for meal vouchers:"
msgstr "Sous-total éligible en tickets restaurant :" msgstr "Sous-total éligible en tickets restaurant :"
#. module: pos_meal_voucher #. module: pos_meal_voucher
#. openerp-web #. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:110 #: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:120
#, python-format #, python-format
msgid "Eligible subtotal for" msgid "Eligible subtotal for"
msgstr "Sous-total éligible en" msgstr "Sous-total éligible en"
#. module: pos_meal_voucher #. module: pos_meal_voucher
#. openerp-web #. openerp-web
#: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:112 #: code:addons/pos_meal_voucher/static/src/xml/pos_meal_voucher.xml:122
#, python-format #, python-format
msgid "meal vouchers:" msgid "meal vouchers:"
msgstr "tickets restaurant :" msgstr "tickets restaurant :"
...@@ -43,42 +43,33 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -43,42 +43,33 @@ odoo.define("pos_meal_voucher.models", function (require) {
} }
}), 0), this.pos.currency.rounding); }), 0), this.pos.currency.rounding);
}, },
/* point_of_sale/statis/src/js/models.js */ is_meal_voucher_used: function() {
export_for_printing: function(){
var orderlines = [];
var self = this;
var paymentlines = [];
// Add fork&knife symbol on pos ticket for products with meal voucher allowed & when meal voucher is used
var meal_voucher_used = false; var meal_voucher_used = false;
this.paymentlines.each(function(paymentline){ this.paymentlines.each( function(paymentline) {
var line = paymentline.export_for_printing();
paymentlines.push(line);
if (paymentline.is_meal_voucher()) { if (paymentline.is_meal_voucher()) {
meal_voucher_used = true; meal_voucher_used = true;
return false;
} }
}); });
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74); return meal_voucher_used;
},
/* point_of_sale/statis/src/js/models.js */
export_for_printing: function(){
var orderlines = [];
var self = this;
this.orderlines.each(function(orderline){ this.orderlines.each(function(orderline){
var orderline_for_printing = orderline.export_for_printing() var orderline_for_printing = orderline.export_for_printing();
orderline_for_printing.product_meal_voucher_ok = orderline.product.meal_voucher_ok;
if (
meal_voucher_used === true &&
orderline.product.meal_voucher_ok === true &&
orderline_for_printing.product_name.includes(meal_voucher_symbol) === false
) {
orderline_for_printing.product_name = meal_voucher_symbol + " " + orderline_for_printing.product_name;
} else if (meal_voucher_used === false && orderline_for_printing.product_name.includes(meal_voucher_symbol) === true) {
orderline_for_printing.product_name = orderline_for_printing.product_name.replace(meal_voucher_symbol + " ", "");
}
orderlines.push(orderline_for_printing); orderlines.push(orderline_for_printing);
}); });
var paymentlines = [];
this.paymentlines.each(function(paymentline){
paymentlines.push(paymentline.export_for_printing());
});
var client = this.get('client'); var client = this.get('client');
var cashier = this.pos.cashier || this.pos.user; var cashier = this.pos.cashier || this.pos.user;
var company = this.pos.company; var company = this.pos.company;
...@@ -147,7 +138,7 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -147,7 +138,7 @@ odoo.define("pos_meal_voucher.models", function (require) {
name: shop.name, name: shop.name,
}, },
currency: this.pos.currency, currency: this.pos.currency,
meal_voucher_used: meal_voucher_used, meal_voucher_used: this.is_meal_voucher_used(),
total_meal_voucher_eligible: this.get_total_meal_voucher_eligible() total_meal_voucher_eligible: this.get_total_meal_voucher_eligible()
}; };
......
...@@ -403,39 +403,15 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -403,39 +403,15 @@ odoo.define("pos_meal_voucher.screens", function (require) {
/* point_of_sale/statis/src/js/screens.js */ /* point_of_sale/statis/src/js/screens.js */
screens.ReceiptScreenWidget.include({ screens.ReceiptScreenWidget.include({
render_receipt: function() { render_receipt: function() {
var order = this.pos.get_order(); var order = this.pos.get_order();
var orderlines = order.get_orderlines(); order.meal_voucher_used = order.is_meal_voucher_used();
var paymentlines = order.get_paymentlines();
// Add fork&knife symbol on pos ticket for product with meal voucher allowed & when meal voucher is used
order.meal_voucher_used = false;
for (var i = 0; i < paymentlines.length; i++) {
if (paymentlines[i].is_meal_voucher()) {
order.meal_voucher_used = true;
break;
}
};
var meal_voucher_symbol = String.fromCharCode(0xD83C, 0xDF74);
for (var i = 0; i < orderlines.length; i++) {
if (
order.meal_voucher_used === true &&
orderlines[i].product.meal_voucher_ok === true &&
orderlines[i].product.display_name.includes(meal_voucher_symbol) === false
) {
orderlines[i].product.display_name = meal_voucher_symbol + " " + orderlines[i].product.display_name;
} else if (order.meal_voucher_used === false && orderlines[i].product.display_name.includes(meal_voucher_symbol) === true) {
orderlines[i].product.display_name = orderlines[i].product.display_name.replace(meal_voucher_symbol + " ", "");
}
}
this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{ this.$('.pos-receipt-container').html(QWeb.render('PosTicket',{
widget:this, widget:this,
order: order, order: order,
receipt: order.export_for_printing(), receipt: order.export_for_printing(),
orderlines: orderlines, orderlines: order.get_orderlines(),
paymentlines: paymentlines paymentlines: order.get_paymentlines()
})); }));
} }
}); });
......
...@@ -84,8 +84,13 @@ ...@@ -84,8 +84,13 @@
</t> </t>
</t> </t>
<t t-extend="PosTicket"> <t t-extend="PosTicket"> <!-- Ticket displayed on screen -->
<t t-jquery="table.receipt-total" t-operation="before"> <t t-jquery="table.receipt-orderlines tr td:first" t-operation="prepend"> <!-- Add cutlery on orderline if needed -->
<t t-if="order.meal_voucher_used === true and orderline.get_product().meal_voucher_ok === true">
<i class="fa fa-cutlery" />
</t>
</t>
<t t-jquery="table.receipt-total" t-operation="before"> <!-- meal voucher subtotal-->
<t t-if="order.meal_voucher_used === true"> <t t-if="order.meal_voucher_used === true">
<table class='receipt-eligible-meal-voucher'> <table class='receipt-eligible-meal-voucher'>
<colgroup> <colgroup>
...@@ -93,7 +98,7 @@ ...@@ -93,7 +98,7 @@
<col width='25%' /> <col width='25%' />
</colgroup> </colgroup>
<tr> <tr>
<td>Eligible subtotal for meal vouchers:</td> <td><i class="fa fa-cutlery"/> Eligible subtotal for meal vouchers:</td>
<td class="pos-right-align"> <td class="pos-right-align">
<t t-esc="widget.format_currency(order.get_total_meal_voucher_eligible())"/> <t t-esc="widget.format_currency(order.get_total_meal_voucher_eligible())"/>
</td> </td>
...@@ -103,11 +108,16 @@ ...@@ -103,11 +108,16 @@
</t> </t>
</t> </t>
</t> </t>
<t t-extend="XmlReceipt"> <t t-extend="XmlReceipt"> <!-- Ticket sent to the printer -->
<t t-jquery="div.orderlines line:not([indent]) left" t-operation="prepend"> <!-- hack to get product name line (lines with qty have 'indent' attr) -->
<t t-if='receipt.meal_voucher_used === true and line.product_meal_voucher_ok === true'>
<i class="fa fa-cutlery" />
</t>
</t>
<t t-jquery="div.orderlines" t-operation="after"> <t t-jquery="div.orderlines" t-operation="after">
<t t-if="receipt.meal_voucher_used === true"> <t t-if="receipt.meal_voucher_used === true">
<line><right>--------</right></line> <line><right>--------</right></line>
<line><left>Eligible subtotal for</left></line> <line><left><i class="fa fa-cutlery"/> Eligible subtotal for</left></line>
<line> <line>
<left>meal vouchers:</left> <left>meal vouchers:</left>
<right><value t-att-value-decimals='pos.currency.decimals'><t t-esc='receipt.total_meal_voucher_eligible' /></value></right> <right><value t-att-value-decimals='pos.currency.decimals'><t t-esc='receipt.total_meal_voucher_eligible' /></value></right>
......
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