重写name_search @api.model def name_search(self, name='', args=None, operator='=', limit=100): print('重定义') print(self.env.context) if 'zhuangtai' in self.env.context: type = self.env.context['zhuangtai'] print(type) args.append(('zhuangtai', '=', type)) return super().name_search(name, args, operator, limit)
xml中增加
context="{'zhuangtai':'yx'}"