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

Hi all friends,

I have a problem and here is the scenario:

Scenario:

  1. I have two selection fields,
  2. In the first one, I choose a contact(suppose: Mike)
  3. In the second one, I can see its sub-contact and select one of those (suppose: Jimi)

Now, In the view, the second field shows the selected sub-contact but proceeding with the parent name at the beginning -> Mike, Jimi

I want to see just 'Jimi' without 'Mike'. (Like -> Jimi)

How can I do that?

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

Hi,I suppose the selection field you mentioned is a relational field and in odoo, the default name of model is taken from the field - name(this will be taken as default) or the field that is specified in the _rec_name of the model. Otherwise we can use the name_get function to update the name of the records.

Here's an example of how you can define the default name of a record from a model using name_get function:

class ProfitCenterInherited(models.Model):    
_inherit = 'profit.center'    

def name_get(self):result = []    
for rec in self:result.append((rec.id, '%s - %s' % (rec.short_name,rec.name)))    
return result
To get more information on using name_get function please follow this blog: https://www.cybrosys.com/blog/how-to-use-of-name-get-function-in-odoo

Hope it helps

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
مارس 24
2725
3
أغسطس 25
2453
1
مايو 25
2578
1
أبريل 25
3540
1
أبريل 25
4387