如何在pos_restaurant模块中自定义POS收据



有两个报告," billreceipt"&" posticket"。一个在pos_restaurant中,第二个在point_of_sale模块中。BillReceipt可与POSBox连接的POSBOX合作,而Posticket在没有POSBOX的情况下可以使用。我继承了Posticket并自定义了它,它可以正常工作,但是当我连接POSBox时,BillReceipt就会启用。

addons/point_of_sale/static/src/xml/pos.xml,posticket。

addons/pos_restaurant/static/src/xml/printbill.xml,billReceipt

我想通过用t-name =" billReceipt"继承模板来自定义收据。

<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="BillReceipt">
    <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 class='cashier'>
                    <div>--------------------------------</div>
                    <div>Served by <t t-esc='receipt.cashier' /></div>
                </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='line.price' />
                            </value>
                        </left>
                        <right>
                            <value><t t-esc='line.price_display' /></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/>
        <!-- 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_xml'>
            <t t-raw='receipt.footer_xml' />
        </t>
        <t t-if='!receipt.footer_xml and receipt.footer'>
            <br/>
            <t t-esc='receipt.footer' />
            <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>
</templates>

我打算将当前收据格式完全替换为我在单击付款按钮后立即出现的POS模块中所做的收据格式。而且,是否有可能使该收据与POSBox连接?

如果要继承该QWEB模板报告,则可以通过以下方式进行:

<t t-extend="BillReceipt">
    <t t-jquery='place_where_you_want_to_do_chnage' t-operation='differet_operations'>
    </t>
</t>

在这里您可以使用不同的t-jquery属性,还可以将值传递给字段t-operation您的要求。您可以从此链接中获得更多想法:t-jquery文档

现在,如果要覆盖模板,则只需在自定义模块中调用具有相同ID的相同模板即可。通过这种方式,模板已被覆盖。

最新更新