Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Create another model's report from wizard

By
Jignesh Mehta
on 3/1/16, 4:55 AM 686 views

Hello,


I have one wizard which have start date and end date.

Now, I want report between this two dates for another model.


I can search the record between the dates in model but in the report, wizard's id is pass.

How can i pass this search id which is from another model.


class TreeIssueDateWiseReport(models.TransientModel):

    _name = 'tree.issue.date.wise.report'

    _description = "Tree Issue Date Wise Report"

    start_date = fields.Date('Start Date', required=True)

    end_date = fields.Date('End Date', required=True)


    @api.multi

    def calculate_report(self):

        self.ensure_one()

        data = {}

        data['ids'] = self.env.context.get('active_ids', [])

        data['model'] = self.env.context.get('active_model', 'ir.ui.menu')

        data['form'] = self.read(['start_date', 'end_date'])[0]

        tree_search_obj = self.env['tree.temp'].search([('date', '>=', self.start_date), ('date', '<=', self.end_date)]).ids

        # data['form'] = tree_search_obj

        # docargs = {

            # 'tree': tree_search_obj,

            # 'wizard': self.id,

        # }

        datas = {

            'ids': tree_search_obj,

            'model': 'tree.temp',

            'form': tree_search_obj,

        }

        return {

            'type': 'ir.actions.report.xml',

            'report_name': 'work_order.report_tree_issue_date',

            'datas': datas}

        # self.render_html()

        # return self.env['report'].get_action(self, 'work_order.report_tree_issue_date', data=docargs)]


    @api.multi

    def render_html(self, data=None):

        print "data ::::::::::::::: ", data

        print "self =============== ", self

        report_obj = self.env['report']

        report = report_obj._get_report_from_name('work_order.report_tree_issue_date')

        tree_search_obj = self.env['tree.temp'].search([('date', '>=', self.start_date), ('date', '<=', self.end_date)]).ids

        docargs = {

            'doc_ids': tree_search_obj,

            'doc_model': 'tree.temp',

            'docs': tree_search_obj,

        }

        return report_obj.render('work_order.report_tree_issue_date', docargs)


Thanks in advance,


any update ??

Jignesh Mehta
on 3/1/16, 10:45 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 3/1/16, 4:55 AM
Seen: 686 times
Last updated: 3/1/16, 10:44 PM