On 2018-09-21 01:35, Markus Bala wrote:
> > > Question 3: How to get report in byte in trytond so I can print direct to 
> > > printer through network. Like the link below
> > > 
> > > https://www.zebra.com/us/en/support-downloads/knowledge-articles/ait/Network-Printing-Python-Example.html
> > 
> > You can get the Report class from the pool and call execute on it. This
> > will return the bytes as second element of the response.
> 
> Could you give me example on this? Iam litte bit confuse.
> 
> Currently, I am using Relatio. It should be a dirty hack. I hope can use the 
> method directly from Trytond instead.
> 
> Below is my code:
> 
> from relatorio import Report
> 
> class BarcodeLabel(Workflow, ModelSQL, ModelView):
> 
>         @classmethod
>         def print_lpn(cls, records):
>                 report = Report(abspath(join(dirname(__file__), 'lpn.odt')),
>                         ODT_MIME)
>                 data = report(records=records).render().getvalue()
>                 file_name = join(dirname(__file__), 'output_basic.odt')
>                 open(file_name, 'wb').write(data)

It should be something like:

    @classmethod
    def print_lpn(cls, records):
        pool = Pool()
        Report = pool.get('module.my_report', type='report')
        ext, data, print, name = Report.execute(map(int, records), {})


-- 
Cédric Krier - B2CK SPRL
Email/Jabber: cedric.kr...@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

-- 
You received this message because you are subscribed to the Google Groups 
"tryton-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tryton-dev/20180921085311.jzkbjx3askvyu6nd%40kei.

Reply via email to