Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
9514 มุมมอง

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?

คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.

อวตาร
ละทิ้ง