跳至内容
菜单
此问题已终结
1 回复
2248 查看

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
2724
3
8月 25
2450
1
5月 25
2577
1
4月 25
3539
1
4月 25
4385