Odoo Help

-1

0
3 Answers
0
Avatar

Pawan Sharma

--Pawan Sharma--
SunArc Technologies
1506
| 5 2 7
Bikaner, Índia
--Pawan Sharma--


Pawan Sharma
25/05/18 02:10

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>


0
Felipe Lopes
25/05/18 12:20

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>


1 Comment
subbarao
08/10/18 05:04

check your python file is imported or not in __init__.py

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now