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

时间:2018-02-19 09:27:09

标签: jquery odoo odoo-10 point-of-sale

有两份报告,“BillReceipt”& “PosTicket”。一个在POS_Restaurant中,另​​一个在point_of_sale模块中。 BillReceipt适用于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”继承模板来自定义POS餐厅模块中的收据。

<?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连接?

1 个答案:

答案 0 :(得分:1)

如果您想继承该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 document

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