Browse Source

Jun 21 : [FIX] Bug Fixed 'custom_receipts_for_pos'

pull/257/head
AjmalCybro 2 years ago
parent
commit
c2e4f0d87a
  1. 3
      custom_receipts_for_pos/__manifest__.py
  2. 269
      custom_receipts_for_pos/demo/pos_receipt_views_demo.xml
  3. 3
      custom_receipts_for_pos/static/js/ReceiptScreen/order_receipt.js
  4. 2
      custom_receipts_for_pos/views/point_of_sale_view.xml

3
custom_receipts_for_pos/__manifest__.py

@ -23,7 +23,7 @@
{ {
'name': 'POS Receipt Design', 'name': 'POS Receipt Design',
'version': '16.0.1.0.1', 'version': '16.0.1.0.0',
'summary': """Option to select the customised Receipts for each POS""", 'summary': """Option to select the customised Receipts for each POS""",
'description': "Option to select the customised Receipts for each POS", 'description': "Option to select the customised Receipts for each POS",
'category': 'Point of Sale', 'category': 'Point of Sale',
@ -38,6 +38,7 @@
'views/pos_receipt_views.xml', 'views/pos_receipt_views.xml',
'views/res_config_settings_views.xml', 'views/res_config_settings_views.xml',
], ],
'demo':['demo/pos_receipt_views_demo.xml'],
'assets': { 'assets': {
'point_of_sale.assets': [ 'point_of_sale.assets': [
'custom_receipts_for_pos/static/js/ReceiptScreen/order_receipt.js', 'custom_receipts_for_pos/static/js/ReceiptScreen/order_receipt.js',

269
custom_receipts_for_pos/demo/pos_receipt_views_demo.xml

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Sub Categories -->
<record id="pos_receipt_design1_demo" model="pos.receipt">
<field name="name">Design 1</field>
<field name="design_receipt"><![CDATA[<div class="pos-receipt">
<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"/>:<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_html">
<t t-out="receipt.header_html" />
</t>
<t t-if="!receipt.header_html and receipt.header">
<div style="white-space:pre-line"><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/>
<t t-if="receipt.header">
<div style='text-align:center; font-size:13px'>
<t t-esc="receipt.header" />
</div>
<br />
</t>
<div>
<table class='receipt-orderlines' style="font-size:15px; border-style: double;
border-left: none;border-right: none;border-bottom: none;width: 100%;">
<colgroup>
<col width='40%' />
<col width='30%' />
<col width='30%' />
</colgroup>
<tr style="border-bottom: 1px dashed black;">
<th style="text-align:left;">Product</th>
<th style="text-align:center;">Qty</th>
<th style="text-align:center;">Amount</th>
</tr>
<tr t-foreach="orderlines" t-as="orderline">
<td style="padding-top: 1%;padding-bottom: 1%;">
<t t-esc="orderline.get_product().display_name"/>
<t t-if="orderline.get_discount() > 0">
<div style="font-size: 12px;font-style: italic;color: #808080;">
<t t-esc="orderline.get_discount()"/>% discount
</div>
</t>
<t t-if="orderline.customerNote">
<div style="font-size: 14px;" t-esc="orderline.customerNote"/>
</t>
</td>
<td class="pos-center-align">
<t t-esc="orderline.get_quantity_str_with_unit()"/>
</td>
<td class="pos-center-align">
<t t-esc="widget.pos.format_currency(orderline.get_display_price())"/>
</td>
</tr>
</table>
</div>
<br />
<div style="padding-top: 6px;">
<!-- Subtotal -->
<t t-set='taxincluded' t-value='Math.abs(receipt.subtotal - receipt.total_with_tax) &lt;= 0.000001' />
<t t-if='!taxincluded'>
<br/>
<div style="font-weight: 700; font-size: 14px; border-top:1px dashed;"><span style="margin-left: 40%;">Subtotal : </span><span t-esc='widget.pos.format_currency(receipt.subtotal)' class="pos-receipt-right-align"/></div>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div style="font-weight: 700; font-size: 14px;">
<span style="margin-left: 40%;"><t t-esc='tax.name' /></span>
<span t-esc='widget.pos.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
</t>
<!-- Total -->
<br/>
<div style="font-weight: 700; font-size: 14px;">
<span style="margin-left: 40%;">TOTAL : </span>
<span t-esc='widget.pos.format_currency(receipt.total_with_tax)' class="pos-receipt-right-align"/>
</div>
</div>
<div class='before-footer' />
<br/>
<br/>
<!-- Footer -->
<div class="pos-receipt-order-data">
<div><t t-esc="receipt.name" /></div>
<t t-if="receipt.date.localestring">
<div><t t-esc="receipt.date.localestring" /></div>
</t>
<t t-else="">
<div><t t-esc="receipt.date.validation_date" /></div>
</t>
</div>
<br/><br/>
<div style="font-size: 14px; text-align: center;">
Thank You... Please Visit Again ...
</div>
</div>]]></field>
</record>
<record id="pos_receipt_design2_demo" model="pos.receipt">
<field name="name">Design 2</field>
<field name="design_receipt"><![CDATA[<div class="pos-receipt">
<div style="font-size:13px; text-align: center;">
<t t-esc="widget.pos.company.name"/><br />
Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
</div>
<br/>
<div style="font-size:13px; text-align: center;">
Date :
<t t-if="order.formatted_validation_date">
<t t-esc="order.formatted_validation_date"/>
</t>
<t t-else="">
<t t-esc="order.validation_date"/>
</t>
<br />
Order : <t t-esc="order.name"/><br />
</div>
<br />
<div style="font-size:13px; text-align: center;">
Cashier : <t t-esc='receipt.cashier' /><br />
<t t-if="receipt.partner.name">
Customer : <t t-esc='receipt.partner.name' style="font-style: bold" />
</t>
<br />
</div>
<br/>
<t t-if="receipt.header">
<div style='text-align:center; font-size:13px'>
<t t-esc="receipt.header" />
</div>
<br />
</t>
<div>
<table class='receipt-orderlines' style="font-size:15px; border-style: double;
border-left: none;border-right: none;border-bottom: none;width: 100%;">
<colgroup>
<col width='40%' />
<col width='30%' />
<col width='30%' />
</colgroup>
<tr style="border-bottom: 1px dashed black;">
<th style="text-align:left;">Product</th>
<th style="text-align:center;">Qty</th>
<th style="text-align:center;">Amount</th>
</tr>
<tr t-foreach="orderlines" t-as="orderline">
<td style="padding-top: 1%;padding-bottom: 1%;">
<t t-esc="orderline.get_product().display_name"/>
<t t-if="orderline.get_discount() > 0">
<div style="font-size: 12px;font-style: italic;color: #808080;">
<t t-esc="orderline.get_discount()"/>% discount
</div>
</t>
<t t-if="orderline.customerNote">
<div style="font-size: 14px;" t-esc="orderline.customerNote"/>
</t>
</td>
<td class="pos-center-align">
<t t-esc="orderline.get_quantity_str_with_unit()"/>
</td>
<td class="pos-center-align">
<t t-esc="widget.pos.format_currency(orderline.get_display_price())"/>
</td>
</tr>
</table>
</div>
<br />
<div style="padding-top: 6px;">
<!-- Subtotal -->
<t t-set='taxincluded' t-value='Math.abs(receipt.subtotal - receipt.total_with_tax) &lt;= 0.000001' />
<t t-if='!taxincluded'>
<br/>
<div style="font-weight: 700; font-size: 14px; border-top:1px dashed;"><span style="margin-left: 40%;">Subtotal : </span><span t-esc='widget.pos.format_currency(receipt.subtotal)' class="pos-receipt-right-align"/></div>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div style="font-weight: 700; font-size: 14px;">
<span style="margin-left: 40%;"><t t-esc='tax.name' /></span>
<span t-esc='widget.pos.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
</t>
<!-- Total -->
<br/>
<div style="font-weight: 700; font-size: 14px;">
<span style="margin-left: 40%;">TOTAL : </span>
<span t-esc='widget.pos.format_currency(receipt.total_with_tax)' class="pos-receipt-right-align"/>
</div>
<br/><br/>
</div>
<!-- Payment Lines -->
<t t-foreach='paymentlines' t-as='line'>
<div style="font-size: 14px;border-top:1px dashed;padding-top: 5px;">
<span style="margin-left: 40%;"><t t-esc='line.name' /></span>
<span t-esc='widget.pos.format_currency_no_symbol(line.get_amount())' class="pos-receipt-right-align"/>
</div>
</t>
<br/>
<div class="receipt-change" style="font-size: 14px;">
<span style="margin-left: 40%;">CHANGE : </span>
<span t-esc='widget.pos.format_currency(receipt.change)' class="pos-receipt-right-align"/>
</div>
<br/>
<!-- Extra Payment Info -->
<t t-if='receipt.total_discount'>
<div style="font-size: 14px; border-top:1px dashed;padding-top: 5px;">
<span style="margin-left: 40%;">Discounts : </span>
<span t-esc='widget.pos.format_currency(receipt.total_discount)' class="pos-receipt-right-align"/>
</div>
</t>
<t t-if='taxincluded'>
<t t-foreach='receipt.tax_details' t-as='tax'>
<div style="font-size: 14px;">
<span style="margin-left: 40%;"><t t-esc='tax.name' /></span>
<span t-esc='widget.pos.format_currency_no_symbol(tax.amount)' class="pos-receipt-right-align"/>
</div>
</t>
<div style="font-size: 14px;">
<span style="margin-left: 40%;">Total Taxes : </span>
<span t-esc='widget.pos.format_currency(receipt.total_tax)' class="pos-receipt-right-align"/>
</div>
</t>
<div class='before-footer' />
<!-- Footer -->
<div t-if='receipt.footer_html' style="text-align: center; font-size: 14px;">
<t t-raw='receipt.footer_html'/>
</div>
<div t-if='!receipt.footer_html and receipt.footer' style="text-align: center;font-size: 14px;">
<br/>
<t t-esc='receipt.footer'/>
<br/><br/>
</div>
<div class='after-footer' style="font-size: 14px;">
<t t-foreach='paymentlines' t-as='line'>
<t t-if='line.ticket'>
<br />
<div class="pos-payment-terminal-receipt">
<t t-raw='line.ticket'/>
</div>
</t>
</t>
</div>
<br/><br/>
<div style="font-size: 14px; text-align: center;">
Thank You... Please Visit Again ...
</div>
</div>]]></field>
</record>
</odoo>

3
custom_receipts_for_pos/static/js/ReceiptScreen/order_receipt.js

@ -23,6 +23,7 @@ odoo.define('custom_receipts_for_pos.receipt',function(require){
super.setup(); super.setup();
onMounted(()=>{ onMounted(()=>{
var self=this; var self=this;
if(self.env.pos.config.is_custom_receipt){ if(self.env.pos.config.is_custom_receipt){
var receipt_design=self.env.pos.config.design_receipt var receipt_design=self.env.pos.config.design_receipt
var order=self._receiptEnv.order; var order=self._receiptEnv.order;
@ -40,8 +41,10 @@ odoo.define('custom_receipts_for_pos.receipt',function(require){
var s=new XMLSerializer(); var s=new XMLSerializer();
var newXmlStr=s.serializeToString(xmlDoc); var newXmlStr=s.serializeToString(xmlDoc);
var qweb=new QWeb2.Engine(); var qweb=new QWeb2.Engine();
console.log('receipt', self._receiptEnv)
qweb.add_template('<templates><t t-name="receipt_design">'+newXmlStr+'</t></templates>'); qweb.add_template('<templates><t t-name="receipt_design">'+newXmlStr+'</t></templates>');
var receipt=qweb.render('receipt_design',data);$('div.pos-receipt').replaceWith(receipt); var receipt=qweb.render('receipt_design',data);$('div.pos-receipt').replaceWith(receipt);
console.log(receipt, 'ooooo')
} }
}) })
} }

2
custom_receipts_for_pos/views/point_of_sale_view.xml

@ -9,7 +9,7 @@
</record> </record>
<menuitem <menuitem
id="menu_pos_receipt" id="menu_pos_receipt"
name="Receipt Designs"
parent="point_of_sale.menu_point_config_product" parent="point_of_sale.menu_point_config_product"
action="action_pos_receipt" action="action_pos_receipt"
sequence="50"/> sequence="50"/>

Loading…
Cancel
Save