Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
3772 Widoki

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?

Awatar
Odrzuć
Autor

Thank you Bharat Parmar,

I use _rec_name='nom'

You help me with your comment.

Najlepsza odpowiedź

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)

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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!

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 15
9281
0
kwi 22
2182
1
sie 17
4294
4
kwi 17
4596
3
paź 16
6993