gpt4 book ai didi

python - 将继承字段添加到 TreeView product_uom_categ - Odoo v9

转载 作者:太空宇宙 更新时间:2023-11-04 05:19:27 25 4
gpt4 key购买 nike

我在 product_uom_categ 模型中添加了一个新字段,继承方式如下:

class product_uom_categ(models.Model):
_inherit = 'product.uom.categ'

code_product = fields.Char(string="Código Unidad")

那么在我看来:

<openerp>
<data>
<record id="product_uom_categ_form_view" model="ir.ui.view">
<field name="name">product.uom.categ.form</field>
<field name="model">product.uom.categ</field>
<field name="inherit_id" ref="product.product_uom_categ_form_view" />
<field name="arch" type="xml">
<field name='name' position="after">
<field name="code_product"/>
</field>
</field>
</record>
</data>
</openerp>

它工作正常,虽然我也想在该定义的 TreeView 上看到它,但我找不到方法,例如,在原始 View 模型中,实际上并没有 TreeView 已定义,只是这样的操作:

    <record id="product_uom_categ_form_view" model="ir.ui.view">
<field name="name">product.uom.categ.form</field>
<field name="model">product.uom.categ</field>
<field name="arch" type="xml">
<form string="Units of Measure categories">
<group>
<field name="name"/>
</group>
</form>
</field>
</record>
<record id="product_uom_categ_form_action" model="ir.actions.act_window">
<field name="name">Unit of Measure Categories</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.uom.categ</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a new unit of measure category.
</p><p>
Units of measure belonging to the same category can be
converted between each others. For example, in the category
<i>'Time'</i>, you will have the following units of measure:
Hours, Days.
</p>
</field>
</record>

因此,在 form 上它显示了两个字段,name 和我的新字段 code_product,但是在 TreeView 上,什么都没有,但是还有,在这方面没有什么可以继承的,我应该继承这个 Action 吗?

我卡在这上面了,有什么想法吗?

最佳答案

你是对的。 product.uom.categ 模型没有 TreeView 。 Odoo 使用 name 列生成默认 TreeView 。

只需将 TreeView 定义添加到您的 [your_module]_views.xml 文件。

<record id="product_uom_categ_tree_view" model="ir.ui.view">
<field name="name">product.uom.categ.tree</field>
<field name="model">product.uom.categ</field>
<field name="arch" type="xml">
<tree string="Units of Measure categories">
<field name="name"/>
<field name="code_product"/>
</tree>
</field>
</record>

希望它能解决您的问题。

关于python - 将继承字段添加到 TreeView product_uom_categ - Odoo v9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40791971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com