Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1667 Widoki

Hi, i want to show tax information in each order line of the POS Receipt in Odoo 17. Unfortunately, it seems like tax information is not available by default in Odoo. It seems like I need to patch order line js, but so far I cannot get the tax to show in the front end.

Here is my js code

/** @odoo-module */

import { patch } from "@web/core/utils/patch";
import { Orderline } from "@point_of_sale/app/store/models";

patch(Orderline.prototype, {
getDisplayData() {
const result = super.getDisplayData();
if (this.tax_ids) {
result.tax_ids = this.get_taxes();
}

return result;
},

});

Here is my orderline code:

<?xml version="1.0" encoding="utf-8"?>
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.Orderline" t-inherit-mode="extension">
<xpath expr="//div[hasclass('product-name')]" position="after">
<t t-log="line"/>

<t t-if="line.tax_ids">
<t t-if="line.tax_ids[0]">
<div> Tax:
​<span t-if="line.tax_ids[0].amount" t-esc="line.tax_ids[0].amount"/><span>%</span>
​</div>
</t>
</t>
</xpath>
</t>
</templates>

Is there any other steps needed to extract the tax information of Orderline?

Awatar
Odrzuć
Najlepsza odpowiedź

Hi Ariefa, you can try like this.

for the xml template, if the product always has only one tax, the code call be simplyfied.

<li t-if="line.taxes" class="tax-info">

​<t t-foreach="line.taxes" t-as="tax" t-key="tax.name">

​<t t-if="tax_index !== 0"> | </t>

​<span><t t-esc="tax.name"/> (<t t-esc="tax.amount"/>%)</span>

​</t>

</li>

dont forget in the model.js getDisplayData() add following,

taxes: this.get_applicable_taxes().map(tax => ({

​name: tax.name,

​amount: tax.amount

}))

additionally, if you set different fiscal postions in POS, you can use this function

this._getProductTaxesAfterFiscalPosition()

hope it can help you.

Awatar
Odrzuć
Najlepsza odpowiedź

tax details by default is in odoo in pos order line
in this class : 

export class Order extends PosModel 
you can use this method : get_tax_details()
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
sie 25
419
2
sie 22
1871
0
sty 19
3820
0
lip 23
1601
1
wrz 21
3753