Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
5556 มุมมอง

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?

อวตาร
ละทิ้ง

Better to check the documentation about how to make tree view and extend the original one.

คำตอบที่ดีที่สุด

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ธ.ค. 23
4976
2
เม.ย. 17
5163
3
เม.ย. 25
4958
5
พ.ย. 23
43302
2
ต.ค. 23
6530