On Friday, September 21, 2018 at 3:54:10 PM UTC+7, Cédric Krier wrote:
> 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), {})
Hi Cedric,
I had tried above code. Overall it is working.
But some need to do correction. I had explain the code below.
For others may need in future.
line 1: @classmethod
line 2: def print_lpn(cls, records):
line 3: pool = Pool()
line 4: Report = pool.get('report_name', type='report')
line 5: ext, data, print, name = Report.execute([5,4], {})
Correction:
line 4: it only need "report_name", it do not need the 'module'.
line 5: it use [5,4] "ids" as parameter
>
>
> --
> Cédric Krier - B2CK SPRL
> Email/Jabber: [email protected]
> 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/b2ef1740-41eb-4bc6-ba6f-9f773625a635%40googlegroups.com.