跳至内容
菜单
此问题已终结

Hi,

I can't see the value of field Many2one: propietari. I install the application and the value of propietari is: taller.propietaris, 1. I only see the class and the ID of the database.

I have the following code:

taller.py

#-*-encoding:utf-8-*-from openerp import models, fields

class taller_propietaris(models.Model):

        _name= 'taller.propietaris'

        nom= fields.Char('Nom', size=150, required=True)

        telf= fields.Char('Telèfon', size=9)

        adreca= fields.Char('Adreça', size=50)

class taller_cotxes(models.Model):

        _name= 'taller.cotxes'

        marca= fields.Char('Marca', size=50)

        precio= fields.Char('Model', size=50)

        color= fields.Char('Model', size=10)

        portes=fields.Integer('Portes')

        matricula= fields.Char('Matricula', size=7)

        bastidor= fields.Char('Bastidor', size=20)

        comentaris= fields.Text('Comentaris')

        propietari= fields.Many2one('taller.propietaris', 'Propietari')

taller_view.xml

<record id="taller.cotxes_form" model="ir.ui.view">

<field name="name">taller.cotxes.form</field>

<field name="model">taller.cotxes</field>

<field name="type">form</field>

<field name="arch" type="xml">

    <form>

        <sheet>

            <group>

                <field name="marca"/>

                <field name="precio"/>

                <field name="color"/>

                <field name="portes"/>

                <field name="matricula"/>

                <field name="marca"/>

                <field name="bastidor"/>

                <field name="comentaris"/>

                <field name="propietari"/>

            </group>

        </sheet>

    </form>

</field>

</record>


How can I see the value of field Many2one?

形象
丢弃
编写者

Thank you Bharat Parmar,

I use _rec_name='nom'

You help me with your comment.

最佳答案

you have not declared the name field in taller.propietaris module. So you can do this in two way.

1) declare name field

class taller_propietaris(models.Model):
     _name= 'taller.propietaris'
     
     name= fields.Char('Nom', size=150, required=True)
     telf= fields.Char('Telèfon', size=9)
     adreca= fields.Char('Adreça', size=50)

or

2) use _rec_name to define name field

class taller_propietaris(models.Model):
     _name= 'taller.propietaris'
     _rec_name = 'nom'     

     nom= fields.Char('Nom', size=150, required=True)
     telf= fields.Char('Telèfon', size=9)
     adreca= fields.Char('Adreça', size=50)

形象
丢弃
编写者 最佳答案

I try:

class taller_propietaris(models.Model):

        _name= 'taller.propietaris'       

        rec_name = 'nom'               

        nom= fields.Char('Nom', size=150, required=True)       

        telf= fields.Char('Telèfon', size=9)       

        adreca= fields.Char('Adreça', size=50)

But I can't see the value.

Thank you NIyas Raphy!

形象
丢弃
相关帖文 回复 查看 活动
2
3月 15
9320
0
4月 22
2225
1
8月 17
4336
4
4月 17
4684
3
10月 16
7034