如何在 Odoo 的 product.supplierinfo.tree.view 上显示产品类别名称?

How to display product category name on product.supplierinfo.tree.view on Odoo?

我想在 Odoo product.supplierinfo.tree.view 中显示相关产品类别名称?

这里是 供应商价目表捕获 :

只需创建一个 related field:

product_category = fields.Many2one(
    string='Product Category',
    related='product_tmpl_id.category_id',
    comodel_name='product.category',
)

并像往常一样将其添加到树视图中:

<record id="product_supplierinfo_tree_view" model="ir.ui.view">
    <field name="name">product.supplierinfo.tree.view</field>
    <field name="model">product.supplierinfo</field>
    <field name="inherit_id" ref="product.product_supplierinfo_tree_view" />
    <field name="arch" type="xml">
        <field name="name" position="after">
            <field name="product_category" />
        </field>
    </field>
</record>