【问题标题】:How to extend a qweb template in Odoo?如何在 Odoo 中扩展 qweb 模板?
【发布时间】:2017-09-23 02:10:25
【问题描述】:

我正在尝试扩展销售点、模板以修改网络票和印刷版......我想放置一个 id 为 numbe 的代码栏。但是阅读和测试我的代码不起作用......为了测试目的,我在模板的几个部分中放置了一个文本以观察它是否被修改......但事实并非如此。

<?xml version="1.0" encoding="UTF-8"?> 
<templates xml:space="preserve">
            <t t-extend="XmlReceipt">
                 <t t-jquery=".receipt-change" t-operation="inner">
                    <div><span>hello world</span></div>
                 </t>
            </t>
            <t t-extend="PosTicket">
                <t t-jquery=".receipt-orderlines .product_line" t-operation="inner">
                    <div><span>hello world</span></div>
                </t>
            </t>
            <t t-extend="PaymentScreenWidget">
                <t t-jquery="div.pos-payment-container" t-operation="inner">
                    <div>
                       Payment Screen Modified
                    </div>
                </t>
            </t>
 </templates>

此代码位于文件名 pos.xml 中,我将其从 openerp.py 中附加如下:

'qweb': ['static/src/xml/pos.xml'],

为什么 XmlReceipt 或 PosTicket 或支付模板没有扩展???? 然后当我成功扩展模板时,我会尝试用

替换 hello world
<barcode encoding="CODE128"><t t-esc="o.id"/></barcode>

谢谢!

[编辑] 好的,现在我正在扩展模板,但是我无法从 order.sequence_number 生成条形码

我正在尝试这样:

<img class="img-responsive" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' % ('Code128', order.sequence_number, 500, 100)" style="width:250px;height:50px;"/>

条形码不是这样生成的......但如果我这样做,它就是

<img t-att-src="'/report/barcode/Code128/*mycode*'" style="width:250px;height:50px;"/>

所以我认为错误在于字符串渲染.....

【问题讨论】:

  • 您想在 XmlReceipt 或 PostTicekt 中添加条形码?

标签: openerp odoo-9 qwebview qweb


【解决方案1】:

这就是我在 odoo-10 中扩展邮件聊天的方式,它对我来说工作得很好。 看看,如果仍然需要,可能会有所帮助。

<templates>

    <!--
        Chatter composer
    -->
    <t t-extend="mail.chatter.ChatComposer">
        <!-- Insert information before the composer -->
        <t t-jquery=".o_composer_suggested_partners" t-operation="replace">
            <!-- List of followers -->
            <div class="o_composer_suggested_partners">
                <t t-foreach='widget.suggested_partners' t-as='recipient'>
                    <div t-attf-title="Add as recipient and follower (reason: #{recipient.reason})">
                        <input type="checkbox" t-att-data-fullname="recipient.full_name"/>
                        <t t-esc="recipient.name"/>
                        <t t-if="recipient.email_address">(<t t-esc="recipient.email_address"/>)</t>
                    </div>
                </t>
            </div>
        </t>
    </t>
</templates>

【讨论】:

    猜你喜欢
    • 2023-01-25
    • 1970-01-01
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多