This question has been flagged
1 Reply
15863 Views

Hi guys,

I would like to have the POS receipt include the tax-amount in the price per product.
For example if you would buy a product thats costs 1.00 and the tax rate is 21% I want the line to show 1.21€.
In point_of_sale/static/src/xml/pos.xml is the PosTicket which displays the ticket in the browser (and makes the PDF too if you wish). So I've changed this:

                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(orderline.get_display_price())"/>
                    </td>

With this:

                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(orderline.get_price_with_tax())"/>
                    </td>

When I now print the ticket in browser everything is fine and the price is shown with the tax amount included in the price on a line. For example:

However, when I now print this ticket with my receipt printer the prices are still shown without these taxes included on the lines. So my question is.. which report is then responsible for the ticket and how can I make it show the prices including taxes? I can't find it anywhere under the reports.. In browser and on PDF it works fine but not when I print the ticket out with the ticket printer. I assume this is controlled/changed by another report?

With kind regards,
Yenthe

Avatar
Discard

Nice find. I've removed my earlier comments, to avoid confusing anyone.

Author

Thanks Shawn! I've removed mine too and only left my answer there. Hopefully this can help others! It had me confused for hours.

Author Best Answer

Alright found the solution myself.
Odoo went in a bit of a weird way here really. The ticket that is shown in your browser and that is printed in the PDF is not the same XML code as for the ticket that the ticket prints.
PosTicket is responsible for printing it on screen and in the PDF and XmlReceipt is responsible for printing with the ticket printer.

If you want to show prices with taxes when the ticket prints it should be like this:

<value><t t-esc='Math.abs(line.price_display + line.tax)' /></value>

In place of:

<value><t t-esc='line.price_display' /></value>

The code that prints out the ticket on screen and in your PDF is from PosTicket in pos.xml (addons/point_of_sale/static/src/xml/pos.xml):

<t t-name="PosTicket">
        <div class="pos-sale-ticket">
            
            <div class="pos-center-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' +
                Date.CultureInfo.formatPatterns.longTime)"/> <t t-esc="order.get('name')"/></div>
            <br />
            <t t-esc="widget.pos.company.name"/><br />
            Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
            User: <t t-esc="widget.pos.cashier ? widget.pos.cashier.name : widget.pos.user.name"/><br />
            Shop: <t t-esc="widget.pos.shop.name"/><br />
            <br />
            <t t-if="widget.pos.config.receipt_header">
                <div style='text-align:center'>
                    <t t-esc="widget.pos.config.receipt_header" />
                </div>
                <br />
            </t>
            <table>
                <colgroup>
                    <col width='50%' />
                    <col width='25%' />
                    <col width='25%' />
                </colgroup>
                <tr t-foreach="orderlines" t-as="orderline">
                    <td>
                        <t t-esc="orderline.get_product().display_name"/>
                         <t t-if="orderline.get_discount() > 0">
                            <div class="pos-disc-font">
                                With a <t t-esc="orderline.get_discount()"/>% discount
                            </div>
                        </t>
                    </td>
                    <td class="pos-right-align">
                        <t t-esc="orderline.get_quantity_str_with_unit()"/>
                    </td>
                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(orderline.get_price_with_tax())"/>
                    </td>
                </tr>
            </table>
            <br />
            <table>
                <tr>
                    <td>Subtotal:</td>
                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(order.getSubtotal())"/>
                    </td>
                </tr>
                <t t-foreach="order.getTaxDetails()" t-as="taxdetail">
                    <tr>
                        <td><t t-esc="taxdetail.tax.name" /></td>
                        <td class="pos-right-align">
                            <t t-esc="widget.format_currency(taxdetail.amount)" />
                        </td>
                    </tr>
                </t>
                <tr>
                    <td>Discount:</td>
                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(order.getDiscountTotal())"/>
                    </td>
                </tr>
                <tr class="emph">
                    <td>Total:</td>
                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(order.getTotalTaxIncluded())"/>
                    </td>
                </tr>
            </table>
            <br />
            <table>
                <tr t-foreach="paymentlines" t-as="line">
                    <td>
                        <t t-esc="line.name"/>
                    </td>
                    <td class="pos-right-align">
                        <t t-esc="widget.format_currency(line.get_amount())"/>
                    </td>
                </tr>
            </table>
            <br />
            <table>
                <tr><td>Change: </td><td class="pos-right-align">
                    <t t-esc="widget.format_currency(order.getChange())"/>
                    </td></tr>
            </table>
            <t t-if="widget.pos.config.receipt_footer">
                <br />
                <div style='text-align:center'>
                    <t t-esc="widget.pos.config.receipt_footer" />
                </div>
            </t>
        </div>
    </t>

The code that prints out the ticket from the ticker printer comes from XmlReceipt in pos.xml (addons/point_of_sale/static/src/xml/pos.xml):

    <t t-name="XmlReceipt">
        <receipt align='center' width='40' value-thousands-separator='' >
            <t t-if='receipt.company.logo'>
                <img t-att-src='receipt.company.logo' />
                <br/>
            </t>
            <t t-if='!receipt.company.logo'>
                <h1><t t-esc='receipt.company.name' /></h1>
                <br/>
            </t>
            <div font='b'>
                <t t-if='receipt.shop.name'>
                    <div><t t-esc='receipt.shop.name' /></div>
                </t>
                <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>VAT:<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>--------------------------------</div>
                    <div>Served by <t t-esc='receipt.cashier' /></div>
                </t>
            </div>
            <br /><br />

            <!-- Orderlines -->

            <div line-ratio='0.6'>
                <t t-foreach='receipt.orderlines' t-as='line'>
                    <t t-set='simple' t-value='line.discount === 0 and line.unit_name === "Unit(s)" and line.quantity === 1' />
                    <t t-if='simple'>
                        <line>
                            <left><t t-esc='line.product_name' /></left>
                            <right><value><t t-esc='line.price_display' /></value></right>
                        </line>
                    </t>
                    <t t-if='!simple'>
                        <line><left><t t-esc='line.product_name' /></left></line>
                        <t t-if='line.discount !== 0'>
                            <line indent='1'><left>Discount: <t t-esc='line.discount' />%</left></line>
                        </t>
                        <line indent='1'>
                            <left>
                                <value value-decimals='3' value-autoint='on'>
                                    <t t-esc='line.quantity' />
                                </value>
                                <t t-if='line.unit_name !== "Unit(s)"'>
                                    <t t-esc='line.unit_name' /> 
                                </t>
                                <!--x 
                                <value value-decimals='2'>
                                    <t t-esc='Math.abs(line.price + line.tax)' />
                                </value>-->
                            </left>
                            <right>
                                <value><t t-esc='Math.abs(line.price_display + line.tax)' /></value>
                            </right>
                        </line>
                    </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'>
                <line><right>--------</right></line>
                <line><left>Subtotal</left><right> <value><t t-esc="receipt.subtotal" /></value></right></line>
                <t t-foreach='receipt.tax_details' t-as='tax'>
                    <line>
                        <left><t t-esc='tax.name' /></left>
                        <right><value><t t-esc='tax.amount' /></value></right>
                    </line>
                </t>
            </t>

            <!-- Total -->

            <line><right>--------</right></line>
            <line size='double-height'>
                <left><pre>        TOTAL</pre></left>
                <right><value><t t-esc='receipt.total_with_tax' /></value></right>
            </line>
            <br/><br/>

            <!-- Payment Lines -->

            <t t-foreach='receipt.paymentlines' t-as='line'>
                <line>
                    <left><t t-esc='line.journal' /></left>
                    <right><value><t t-esc='line.amount'/></value></right>
                </line>
            </t>
            <br/> 

            <line size='double-height'>
                <left><pre>        CHANGE</pre></left>
                <right><value><t t-esc='receipt.change' /></value></right>
            </line>
            <br/>
            
            <!-- Extra Payment Info -->

            <t t-if='receipt.total_discount'>
                <line>
                    <left>Discounts</left>
                    <right><value><t t-esc='receipt.total_discount'/></value></right>
                </line>
            </t>
            <t t-if='taxincluded'>
                <t t-foreach='receipt.tax_details' t-as='tax'>
                    <line>
                        <left><t t-esc='tax.name' /></left>
                        <right><value><t t-esc='tax.amount' /></value></right>
                    </line>
                </t>
            </t>

            <!-- Footer -->
            <t t-if='receipt.footer'>
                <br/>
                <pre><t t-esc='receipt.footer' /></pre>
                <br/>
                <br/>
            </t>

            <br/>
            <div font='b'>
                <div><t t-esc='receipt.name' /></div>
                <div><t t-esc='receipt.date.localestring' /></div>
            </div>

        </receipt>
    </t>

Avatar
Discard