[FIX] point_of_sale, pos_restaurant: print bill with correct template

Until now, the ticket printed from the web or to the printer were
different because one was using the OrderReceipt template and removed
some fields, and the other was using the BillReceipt.

We are now using only the bill receipt, to avoid to maintain multiple
template showing the same thing.

TASK-ID: 47990
This commit is contained in:
Pierre Masereel
2019-10-01 10:02:49 +00:00
parent 69dc97c698
commit b213c9ee3c
3 changed files with 19 additions and 147 deletions
+1 -1
View File
@@ -1003,7 +1003,7 @@
</t>
<br/>
<div class="pos-receipt-amount">
<div class="pos-receipt-amount receipt-change">
CHANGE
<span t-esc='widget.format_currency_no_symbol(receipt.change)' class="pos-receipt-right-align"/>
</div>
@@ -15,35 +15,30 @@ var BillScreenWidget = screens.ReceiptScreenWidget.extend({
click_back: function(){
this.gui.show_screen('products');
},
get_receipt_render_env: function(){
var render_env = this._super();
render_env.receipt.bill = true;
return render_env;
},
render_receipt: function(){
this._super();
this.$('.receipt-paymentlines').remove();
this.$('.receipt-change').remove();
},
print_web: function(){
window.print();
},
});
gui.define_screen({name:'bill', widget: BillScreenWidget});
var PrintBillButton = screens.ActionButtonWidget.extend({
template: 'PrintBillButton',
print_html: function(){
var order = this.pos.get('selectedOrder');
if(order.get_orderlines().length > 0){
var receipt = order.export_for_printing();
receipt.bill = true;
this.pos.proxy.printer.print_receipt(QWeb.render('BillReceipt',{
receipt: receipt, widget: this, pos: this.pos, order: order,
}));
}
},
button_click: function(){
if (!this.pos.config.iface_print_via_proxy) {
var order = this.pos.get('selectedOrder');
if(order.get_orderlines().length > 0) {
this.gui.show_screen('bill');
} else {
this.print_html();
this.gui.show_popup('error', {
'title': _t('Nothing to Print'),
'body': _t('There is no order lines'),
});
}
},
});
@@ -51,12 +46,12 @@ var PrintBillButton = screens.ActionButtonWidget.extend({
screens.define_action_button({
'name': 'print_bill',
'widget': PrintBillButton,
'condition': function(){
'condition': function(){
return this.pos.config.iface_printbill;
},
});
return {
BillScreenWidget: BillScreenWidget,
PrintBillButton: PrintBillButton,
}
};
});
@@ -33,135 +33,12 @@
</span>
</t>
<t t-name="BillReceipt">
<div class="pos-receipt">
<t t-if='receipt.company.logo'>
<img class="pos-receipt-logo" t-att-src='receipt.company.logo' alt="Logo"/>
<br/>
<t t-extend="OrderReceipt">
<t t-jquery='.pos-receipt-order-data' t-operation='append'>
<t t-if='receipt.bill === true'>
<div>PRO FORMA</div>
</t>
<t t-if='!receipt.company.logo'>
<h1 class="pos-receipt-center-align">
<t t-esc='receipt.company.name' />
</h1>
<br/>
</t>
<div class="pos-receipt-contact">
<t t-if='receipt.company.contact_address'>
<div><t t-esc='receipt.company.contact_address' /></div>
</t>
<t t-if='receipt.company.phone'>
<div>Tel:<t t-esc='receipt.company.phone' /></div>
</t>
<t t-if='receipt.company.vat'>
<div><t t-esc="receipt.company.vat_label or 'Tax ID'"/>:<t t-esc='receipt.company.vat' /></div>
</t>
<t t-if='receipt.company.email'>
<div><t t-esc='receipt.company.email' /></div>
</t>
<t t-if='receipt.company.website'>
<div><t t-esc='receipt.company.website' /></div>
</t>
<t t-if='receipt.header'>
<div><t t-esc='receipt.header' /></div>
</t>
<t t-if='receipt.cashier'>
<div class='cashier'>
<div>--------------------------------</div>
<div>Served by <t t-esc='receipt.cashier' /></div>
</div>
</t>
</div>
<br /><br />
<!-- Orderlines -->
<div class='orderlines'>
<t t-foreach='receipt.orderlines' t-as='line'>
<t t-set='simple' t-value='line.discount === 0 and line.unit_name === "Units" and line.quantity === 1' />
<t t-if='simple'>
<div>
<t t-esc='line.product_name' />
<span t-esc='widget.format_currency_no_symbol(line.price_display)' class="pos-receipt-right-align"/>
</div>
</t>
<t t-if='!simple'>
<div><t t-esc='line.product_name' /></div>
<t t-if='line.discount !== 0'>
<div class="pos-receipt-left-padding">Discount: <t t-esc='line.discount'/>%</div>
</t>
<div class="pos-receipt-left-padding">
<t t-esc='Math.round(line.quantity * 1000) / 1000' />
<t t-if='line.unit_name !== "Units"'>
<t t-esc='line.unit_name' />
</t>
x
<t t-esc='widget.format_currency_no_symbol(line.price)'/>
<span t-esc='widget.format_currency_no_symbol(line.price_display)' class="price-display pos-receipt-right-align"/>
</div>
</t>
</t>
</div>
<!-- Subtotal -->
<t t-set='taxincluded' t-value='Math.abs(receipt.subtotal - receipt.total_with_tax) &lt;= 0.000001' />
<t t-if='!taxincluded'>
<div class="pos-receipt-right-align">--------</div>
<br/>
<div>Subtotal<span t-esc='widget.format_currency_no_symbol(receipt.subtotal)' class="pos-receipt-right-align"/></div>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div>
<t t-esc='tax.name' />
<span t-esc='widget.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
</t>
<!-- Total -->
<div class="pos-receipt-right-align">--------</div>
<br/>
<div class="pos-receipt-amount">
TOTAL
<span t-esc='widget.format_currency_no_symbol(receipt.total_with_tax)' class="pos-receipt-right-align"/>
</div>
<br/><br/>
<!-- Extra Payment Info -->
<t t-if='receipt.total_discount'>
<div>
Discounts
<span t-esc='widget.format_currency_no_symbol(receipt.total_discount)' class="pos-receipt-right-align"/>
</div>
</t>
<t t-if='taxincluded'>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div>
<t t-esc='tax.name' />
<span t-esc='widget.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
</t>
<!-- Footer -->
<t t-if='receipt.footer_html'>
<t t-raw='receipt.footer_html' class="pos-receipt-center-align"/>
</t>
<t t-if='!receipt.footer_html and receipt.footer'>
<br/>
<t t-esc='receipt.footer' class="pos-receipt-center-align"/>
<br/>
<br/>
</t>
<br/>
<div class="pos-receipt-order-data">
<div><t t-esc='receipt.name' /></div>
<div><t t-esc='receipt.date.localestring' /></div>
</div>
</div>
</t>
</t>
</templates>