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

Launch qweb report from Python code

By
José
on 5/2/16, 7:54 AM 733 views

Hello, I have Odoo 8. I developed a wizard, and I want to launch a qweb report (which I have developed in a xml file and works fine) when the user press "OK" button in the wizard. How can I launch the report from the Python method for "OK"?

Thanks!   

1
Krupesh Laiya
On 5/3/16, 5:41 AM

for new api

@api.multi

def invoice_print(self):

    """ Print the invoice and mark it as sent, so that we can see more

      easily the next step of the workflow

     """

   assert len(self) == 1, 'This option should only be used for a single id at a time.'

  self.sent = True

   return self.env['report'].get_action(self, 'account.report_invoice')

for old api

    def print_quotation(self, cr, uid, ids, context=None):

'''

This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow

'''

assert len(ids) == 1, 'This option should only be used for a single id at a time'

self.signal_workflow(cr, uid, ids, 'quotation_sent')

return self.pool['report'].get_action(cr, uid, ids, 'sale.report_saleorder', context=context)

1

Jignesh Mehta

--Jignesh Mehta--
2087
| 6 4 8
Surat, India
--Jignesh Mehta--


Jignesh Mehta
On 5/2/16, 8:50 AM

Hello Jose,


Try below method on click of Wizard button.


@api.multi

def print_report(self):

    report_obj = self.env['model.name'].search([]).ids

    datas = {

        'ids': report_obj,

        'model': 'model.name',

        'form': report_obj,

    }

    return {

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

        'report_name': 'module_name.report_id',

        'datas': datas,

    }


Hope it works for you.

Thanks,

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 5/3/16, 5:02 AM

hello,

You can also use get_action as here

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

1 follower(s)

Stats

Asked: 5/2/16, 7:54 AM
Seen: 733 times
Last updated: 5/3/16, 5:41 AM