跳至內容
選單
此問題已被標幟
1 回覆
2250 瀏覽次數

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
3月 24
2725
3
8月 25
2453
1
5月 25
2578
1
4月 25
3540
1
4月 25
4387