【问题标题】:XML attribute tagXML 属性标记
【发布时间】:2018-09-06 08:56:35
【问题描述】:

请帮助我准确理解这部分代码(带有 Odoo 的 XML)<attribute> 标签

<xpath expr="//tree/field[@name='account_id']" position="attributes">
    <attribute name="invisible">1</attribute> 
</xpath>

<xpath expr="//field[@name='number']" position="attributes">
    <attribute name="string">PO Number</attribute>
    <attribute name="readonly">0</attribute>
</xpath>

【问题讨论】:

  • 不是python问题。

标签: xml odoo


【解决方案1】:

第一个 XPath 表达式使嵌入树视图的字段 account_id 不可见。实际上,它是将属性 invisible="1" 添加到如下所示的字段中:

<tree>
    <field name="name" />
    <!-- some other fields -->
    <field name="account_id" invisible="1" />
</tree>

第二个 XPath 为第一个字段定义添加/更改属性 string 和 readonly,属性 name 等于继承视图中的“数字”。 string 是该视图中的字段标签,显然已更改为不同于通常标签的内容,并且通常该字段似乎是只读的,readonly="0" 将其更改为可读。

【讨论】:

    【解决方案2】:

    这意味着:

    1. invisble = 1 ===> 计算字段并将其隐藏。
    2. name ===> 当前字段的标签。
    3. readonly = 0 ===> 我们可以编辑这个字段的值。

    如果readonly = 1 可以看到该字段,但我们无法编辑该字段

    【讨论】:

      猜你喜欢
      • 2011-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 2012-02-18
      • 2021-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多