How i make a table treeview with a custom char column editable
I get some columns from a model and want insert a custom column. How i make this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How i make a table treeview with a custom char column editable
I get some columns from a model and want insert a custom column. How i make this?
Hello @Felipe Lopes,
I think you want show custom fields in tree view. For this first inherit model in both python and xml.
For ex. Python file:
class sale_order_pet(models.Model):
_inherit = "sale.order"
id = fields.Integer()
sale_remark = fields.Text("Sales Remark")
XML File:
<record model="ir.ui.view" id="custom_order_form">
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="name">Sale Order Form</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='partner_id']" position="before">
<field name="id" string="Customer ID"/>
<field name="sale_remark"/>
</xpath>
</data>
</field>
</record>
<record model="ir.ui.view" id="custom_order_tree">
<field name="inherit_id" ref="sale.view_order_tree"/>
<field name="name">Sale Order Tree</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='partner_id']" position="before">
<field name="id" string="Customer ID"/>
<field name="sale_remark"/>
</xpath>
</data>
</field>
</record>
Thanks @Pawan Sharma
I tried to do as shown in the code below.
I received the error:
<pre>
ParseError: "Error while validating constraint
Field `qualidade_resultado` does not exist
</pre>
My View:
<pre>
class QualidadeMrp(models.Model):
_inherit = "mrp.production"
qualidade_ids = fields.One2many('tr.qualidade', 'production_id')
qualidade_resultado = fields.Char('Resultado', default="Não medido")
</pre>
My Model:
<pre>
<record model="ir.ui.view" id="custom_order_form">
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="name">Controle de Qualidade</field>
<field name="model">mrp.production</field>
<field name="arch" type="xml">
<data>
<xpath expr="//field[@name='move_raw_ids']/.." position="after">
<page string="Controle da Qualidade">
<field name="qualidade_ids">
<tree string="Itens do controle de qualidade">
<field name="qua_propriedade" string="Propriedade"/>
<field name="qua_especificacao" string="Especificação"/>
<field name="qualidade_resultado" string="Resultado Obtido"/>
</tree>
</field>
</page>
</xpath>
</data>
</field>
</record>
</pre>
check your python file is imported or not in __init__.py
Better to check the documentation about how to make tree view and extend the original one.