Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
3768 Zobrazení

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
Zrušit
Autor

Thank you Bharat Parmar,

I use _rec_name='nom'

You help me with your comment.

Nejlepší odpověď

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
Zrušit
Autor Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
bře 15
9274
0
dub 22
2175
1
srp 17
4290
4
dub 17
4576
3
říj 16
6985