# -*- coding: utf-8 -*-
import wizard
import model
import interface
import controllers
import odoo


def action_for_report_search(self):
    '''
    动态生成的报表查询器执行该方法，打开对应的报表。
    :param self:
    :return:
    '''
    report_id = self.env.context['report_id']
    wizard_id = self.id or self.env.context['wizard_id']
    datasource_id = self.env.context['datasource_id']

    return {
        'type': 'ir.actions.act_url',
        'url': '/v1/jd_report/preview?id=%d&wizard_id=%d&wizard_model=%s&src=%d' % (report_id, wizard_id, self._name, datasource_id),
        'target': 'new',
    }

odoo.models.Model.action_for_report_search = action_for_report_search
