【问题标题】:odoo, qweb: I like to replace attribute's value in odoo reportodoo,qweb:我喜欢在 odoo 报告中替换属性值
【发布时间】:2022-03-27 06:10:16
【问题描述】:

在 odoo 中,qweb 报告。我创建了一个继承报告,其目标是将 t-call 属性值从 internal_layout 更改为外部布局。我使用了下一个代码:

<template id="!!!!!!!!!!!!"  inherit_id="!!!!!!!!!!!!!">
            <xpath expr="//t[@t-call='web.internal_layout']"  position="attributes">
                <attribute name="attrs">{'t-call':'web.external_layout'}</attribute>
            </xpath>
        </template>

此代码不起作用,我想知道是否有办法插入同一报告的子部分。

<template id="!!!!!!!!!!!!!!!!!!"  inherit_id="!!!!!!!!!!!">
            <xpath expr="//t[@t-call='web.internal_layout']"  position="replace">
                <t t-call='web.external_layout'>
                    insert here original sub report
                 </t>
            </xpath>
        </template>

【问题讨论】:

    标签: qweb odoo-13


    【解决方案1】:

    这个小改动可以操作!

    <data>
    <template id="!!!!!!!!!!"  inherit_id="!!!!!!!!!!!!!!!!!">
                <xpath expr="//t[@t-call='web.internal_layout']"  position="attributes">
                    <attribute name="t-call">web.external_layout</attribute>
                </xpath>
            </template>
    </data>

    【讨论】:

      【解决方案2】:

      如果您的视图是针对多个对象的,例如包含:

      &lt;t t-set="o" t-value="o.with_context({'lang':o.customer_id.lang})" /&gt;

      你必须添加其他属性修改:

      <xpath expr="//t[@t-call='web.internal_layout']"  position="attributes">
           <attribute name="t-call">web.external_layout</attribute>
           <attribute name="t-foreach">docs</attribute>
           <attribute name="t-as">o</attribute>
      </xpath>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多