栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

odoo-2个字段的many2one字段组合的显示名称

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

odoo-2个字段的many2one字段组合的显示名称

如果您不想更改

many2one
与模型相关的其余部分的显示名称,则
xx.insurance.type
可以在XML视图中向
many2one
要修改其显示名称的上下文中添加一个上下文:

<field name="xx_insurance_type" context="{'special_display_name': True}"/>

然后,在您的

name_get
函数中:

def name_get(self, cr, uid, ids, context=None):    if context is None:        context = {}    if isinstance(ids, (int, long)):        ids = [ids]    res = []    if context.get('special_display_name', False):        for record in self.browse(cr, uid, ids, context=context): name = record.name percentage = record.insurance_percentage res.append(record.id, name + " - " + percentage + "%")    else:        # Do a for and set here the standard display name, for example if the standard display name were name, you should do the next for        for record in self.browse(cr, uid, ids, context=context): res.append(record.id, record.name)    return res


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/640409.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号