如何打开带有滤波数据的模块?无效字段

时间:2016-04-26 08:45:52

标签: python xml openerp odoo-8

我添加了一个模块" Base Candidat"在这个模块base.candidat我想打开一个特定的canidate的应用程序(与候选人有相同的电子邮件) 我将此函数添加到base_candidat.py

def action_get_applications(self, cr, uid, ids, context=None):
    model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'hr_recruitment', 'action_hr_job_applications')
    action = self.pool.get(model).read(cr, uid, action_id, context=context)
    email_ids = self.browse(cr, uid, ids[0], context).email_candidat
    candidature_ids = self.pool.get('hr.applicant').search(cr, uid, [('email_from', '=', email_ids)], context=context)
    action['context'] = {'default_res_model': self._name, 'default_res_id': ids[0]}
    action['domain'] = str([('candidature_ids', 'in', email_ids)])
    return action

我没有结果。 有什么建议??

1 个答案:

答案 0 :(得分:0)

在odoo 8中,您可以尝试以下代码:

@api.multi
def action_get_candidatures(self):
    action_id = self.env.ref('hr_recruitment.action_hr_job_applications')
    action = action_id.read()[0]
    action['context'] = {'default_res_model': self._name, 'default_res_id': self.ids[0]}
    action['domain'] = str(['&', ('res_model', '=', self._name), ('email_from', '=', 'candidat01@exemple.com')])
    return action