Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
2239 Weergaven

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?

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
mrt. 24
2702
3
aug. 25
2372
1
mei 25
2563
1
apr. 25
3520
1
apr. 25
4348