Skip to Content
Menú
This question has been flagged
3 Respostes
9490 Vistes

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

Avatar
Descartar

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

Best Answer

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

Avatar
Descartar
Best Answer

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.

Avatar
Descartar