Ir al contenido
Menú
Se marcó esta pregunta
3 Respuestas
3734 Vistas

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.

Mejor respuesta

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 Mejor respuesta

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
Publicaciones relacionadas Respuestas Vistas Actividad
2
mar 15
9260
0
abr 22
2148
1
ago 17
4278
4
abr 17
4540
3
oct 16
6953