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.

1

How to print automatically from action

By
David Verove
on 11/19/14, 11:12 AM 628 views

Hello,

I have installed the module base_report_to_printer to directly print some reports to printer.

Now, I would like to trigger the reporting when using a validate button (ex : produce invoice from sale.order). So that means I want the server to produce the report and to send it to cups.

Is there any way to do it?

Thanks,

David

Have you tried making the method to return a report action?

Ivan
on 11/20/14, 1:54 AM
0
Ankit Gauri
On 6/17/15, 3:19 AM

hi david

try this

.xml

<button name="Method_name" string="Print Report" type="object"/>

.py

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

    model_obj = self.pool.get("model.name")

    domain = [('assort_id', 'in', ids)]

    model_ids= model_obj.search(cr, uid, domain,context=context)

return self.pool.get('report').get_action(cr, uid, model_ids, 'report_name', context=context)

  Thank you

0
Virali
On 6/17/15, 3:03 AM

On button click you will call this method and in method you will put validation you want and return report after validation.

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

datas = {

'active_ids': ids,

'active_model': 'MODEL OBJECT',

}

return {'type': 'ir.actions.report.xml', 'report_name': 'rREPORT NAME', 'datas': datas, 'nodestroy': True}

Hope you will get your answer.

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: 11/19/14, 11:12 AM
Seen: 628 times
Last updated: 6/17/15, 3:20 AM