Skip to content

Commit

Permalink
[IMP] Overwrite the original template for OrderReceipt
Browse files Browse the repository at this point in the history
  • Loading branch information
ygcarvalh committed Feb 28, 2023
1 parent 1f7611c commit 65dcd77
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 59 deletions.
3 changes: 2 additions & 1 deletion l10n_br_pos_cfe/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"python": ["satcomum"],
},
"data": [
"data/pos_payment_method_data.xml",
# Views
"views/pos_payment_method_view.xml",
# Templates
Expand All @@ -29,7 +30,7 @@
"demo/pos_payment_method_demo.xml",
],
"qweb": [
"static/src/xml/Screens/ReceiptScreen/OrderReceipt.xml",
"static/src/xml/Screens/ReceiptScreen/SatOrderReceipt.xml",
"static/src/xml/Screens/ReceiptScreen/OrderRowReceipt.xml",
"static/src/xml/Screens/ReceiptScreen/OrderHeaderReceipt.xml",
"static/src/xml/Screens/ReceiptScreen/OrderSubtitleReceipt.xml",
Expand Down
8 changes: 8 additions & 0 deletions l10n_br_pos_cfe/data/pos_payment_method_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,12 @@
<field name="sat_payment_mode">05</field>
</record>

<function model="pos.payment.method" name="write">
<value
model="pos.payment.method"
search="[('is_cash_count', '=', True), ('cash_journal_id.type', '=', 'cash')]"
/>
<value eval="{'sat_payment_mode': '01'}" />
</function>

</odoo>
4 changes: 4 additions & 0 deletions l10n_br_pos_cfe/demo/pos_payment_method_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@
<field name="sat_payment_mode">05</field>
</record>

<record id="l10n_br_pos.presumido_dinheiro" model="pos.payment.method">
<field name="sat_payment_mode">01</field>
</record>

</odoo>
14 changes: 14 additions & 0 deletions l10n_br_pos_cfe/static/src/js/ReceiptScreen/SatOrderReceipt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
odoo.define("l10n_br_pos_cfe.SatOrderReceipt", function (require) {
"use strict";

const OrderReceipt = require("point_of_sale.OrderReceipt");

/*
* Overwrite the original component template, as it is giving OWL
* error when we try to inherit and change the information from
* the entire original template.
*/
OrderReceipt.template = "SatOrderReceipt";

return OrderReceipt;
});

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">

<t t-name="SatOrderReceipt" owl="1">
<div class="pos-receipt">
<OrderHeaderReceipt company="receipt.company" />
<p
class="receipt__divider"
>------------------------------------------------</p>
<OrderSubtitleReceipt order="receipt" />
<p
class="receipt__divider"
>------------------------------------------------</p>
<div class="body">
<div class="body__header">
# | COD | DESC | QTD | UN | VLUN R$ | VLTR R$ | VL ITEM R$
</div>
<p
class="receipt__divider"
>------------------------------------------------</p>
<t t-foreach="receipt.orderlines" t-as="line" t-key="line.id">
<OrderRowReceipt line="line" />
</t>
<OrderTotalsReceipt order="receipt" rounding="receipt.rounding" />
<t
t-foreach="receipt.paymentlines"
t-as="paymentline"
t-key="paymentline.id"
>
<OrderPaymentReceipt
paymentline="paymentline"
rounding="receipt.rounding"
/>
</t>
<div class="receipt__change">
<div>
<span>Troco R$</span>
</div>
<div>
<span><t t-esc="receipt.change" /></span>
</div>
</div>
<p
class="receipt__divider"
>------------------------------------------------</p>
</div>
<OrderFooterReceipt />
</div>
</t>

</templates>
4 changes: 4 additions & 0 deletions l10n_br_pos_cfe/views/pos_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
src="/l10n_br_pos_cfe/static/src/js/ReceiptScreen/OrderSubtitleReceipt.js"
type="text/javascript"
/>
<script
src="/l10n_br_pos_cfe/static/src/js/ReceiptScreen/SatOrderReceipt.js"
type="text/javascript"
/>
</xpath>

<xpath expr="//link[@id='pos-stylesheet']" position="after">
Expand Down

0 comments on commit 65dcd77

Please sign in to comment.