[英]How to cancatenate multiple Character fields in one many2one field?
I want to concatenate multiple character fields in a single many2one field and access this in other module. 我想在一个many2one字段中串联多个字符字段,并在其他模块中访问它。 How can we do this?
我们应该怎么做?
For example:- I have 5 character fields with different classes in a module and want to concatenate these 5 character fields in a single many2one field.
例如:-我在一个模块中有5个具有不同类的字符字段,并希望将这5个字符字段连接到单个many2one字段中。 Also I want access this many2one field in another module.
我也想访问另一个模块中的many2one字段。
Can anyone help me out here? 有人可以帮我从这里出去吗?
Use name_get
function. 使用
name_get
函数。
Ex: 例如:
@api.multi
@api.depends('name', 'state')
def name_get(self):
result = []
for move in self:
if move.state == 'draft':
name = '* ' + str(move.id)
else:
name = move.name
result.append((move.id, name))
return result
Hope it will help you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.