تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4176 أدوات العرض

i'm creating a moudle in odoo 11 and i wanna use many2one as selection field , the problem is on the of the city'ville en francais' the dropdown works and it saves the id of the city(from database) but the name is like obj.ville,1(it shows the name of the module, id instead of the name of the city in database)

Code:

from odoo import models, fields, api


Class villeMO(models.Model):

_name = 'ville.mo'

  ville = fields.Char(string="ville",required=True)

       Class paya(models. Model):

_name='paya.mo'

city = fields.Many2one('ville.mo',ondelete="cascade",string="city")


الصورة الرمزية
إهمال
أفضل إجابة

Odoo uses by default the “name” field to display the record as a string (display name), so you could rename the field “ville” to “name”. 

You can also set the attribute “_rec_name” = “ville” to tell Odoo to use the “ville” field for the records display name.

So like this:

Class villeMO(models.Model):

    _name = 'ville.mo'

    _rec_name = 'ville'

    ville = fields.Char(string="ville",required=True)

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

thank you very much for your help

الصورة الرمزية
إهمال

No problem! An upvote would be appreciated :)

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
فبراير 25
3654
0
مايو 24
46
1
أبريل 24
3409
4
سبتمبر 23
4911
2
سبتمبر 23
7126