Skip to Content
Menú
This question has been flagged
3 Respostes
3714 Vistes

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?

Avatar
Descartar
Autor

Thank you Bharat Parmar,

I use _rec_name='nom'

You help me with your comment.

Best Answer

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)

Avatar
Descartar
Autor Best Answer

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!

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de març 15
9240
0
d’abr. 22
2135
1
d’ag. 17
4267
4
d’abr. 17
4513
3
d’oct. 16
6938