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

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?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
mar 24
2737
3
sie 25
2534
1
maj 25
2595
1
kwi 25
3558
1
kwi 25
4412