您的当前位置:首页正文

odoo name_get , name_search

2024-11-29 来源:个人技术集锦
name_get() , 默认计算 display_name 的值
@api.multi
    def name_get(self):
        res = []
        demo = self._context.get('demo', False)
        for record in self:
            name = record.name
            if demo and record.id2:
                name += "[示例:%s, 示例:%s]" % (record.id1, record.id2)
            else:
                if demo:
                    name += "[示例:%s]" % record.id1
                if record.id2:
                    name += "[示例:%s]" % record.id2
            res.append((record.id, name))
        return res
name_search, 通过名称和引用查找记录
@api.model
    def name_search(self, name='', args=None, operator='ilike', limit=100):
        return super(StockProductionLot, self).name_search(name, args, operator, limit)
可参考订单明细选择时,下拉框显示的产品
显示全文