2
votes

I added a new field into product_uom_categ model, by inheriting like this:

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

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

Then in my view:

<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>

It is working fine, although I want to see this also on tree view of that definition, and I can't find a way to do it, for example, in the original view model, there isn't actually a tree view defined, just an action like this:

    <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>

So, on form it shows both fields, name and my new field code_product, but on tree view, there is nothing, but also, there is nothing to inherit in that regard, should I inherit the action?

I'm stuck on this, any ideas?

1

1 Answers

1
votes

You are right. There is no tree view for the product.uom.categ model. Odoo generates a default tree view with the name-column.

Just add a tree view definition to your [your_module]_views.xml file.

<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>

Hopefully it will fix your ploblems.