Download PDF instead of ODT file in report invoice etc.

187 views
Skip to first unread message

zmers...@gmail.com

unread,
Oct 14, 2016, 3:50:09 AM10/14/16
to tryton
Hey Guys

Need Help. 

In generating report/print instead of downloading odt it will convert to pdf and the pdf file will be downloaded directly? by the way i'm using sao client.

I have also check the result for this code

class InvoiceReport(Report):
    __name__ = 'account.invoice'

    @classmethod
    def __setup__(cls):
        super(InvoiceReport, cls).__setup__()
        cls.__rpc__['execute'] = RPC(False)

    @classmethod
    def execute(cls, ids, data):
        Invoice = Pool().get('account.invoice')

        result = super(InvoiceReport, cls).execute(ids, data)
        invoice = Invoice(ids[0])

        if len(ids) > 1:
            result = result[:2] + (True,) + result[3:]
        else:
            if invoice.number:
                result = result[:3] + (result[3] + ' - ' + invoice.number,)

        if invoice.invoice_report_cache:
            result = (invoice.invoice_report_format,
                invoice.invoice_report_cache) + result[2:]
        else:
            # If the invoice is posted or paid and the report not saved in
            # invoice_report_cache there was an error somewhere. So we save it
            # now in invoice_report_cache
            if invoice.state in {'posted', 'paid'} and invoice.type == 'out':
                invoice.invoice_report_format, invoice.invoice_report_cache = \
                    result[:2]
                invoice.save()

        return result

the oext in result or the output extension is in pdf. But still the odt is downloaded. 

Sergi Almacellas Abellana

unread,
Oct 14, 2016, 4:11:49 AM10/14/16
to try...@googlegroups.com
El 14/10/16 a les 03:15, zmers...@gmail.com ha escrit:
> Hey Guys
>
> Need Help.
>
> In generating report/print instead of downloading odt it will convert to
> pdf and the pdf file will be downloaded directly? by the way i'm using
> sao client.
>

Your ir.report record must have pdf extension selected. Then tryton will
use unoconv [1] to convert from odt to pdf. You should configure the
parameters used on your config file. See:

http://doc.tryton.org/4.0/trytond/doc/topics/configuration.html#report

This will work for both tryton client (gtk and sao) as the process is
done on server side.

Hope it helps.

[1] http://dag.wiee.rs/home-made/unoconv/
--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

zmers...@gmail.com

unread,
Oct 17, 2016, 2:10:05 AM10/17/16
to tryton
> Your ir.report record must have pdf extension selected. Then tryton will 
> use unoconv [1] to convert from odt to pdf. You should configure the 
> parameters used on your config file. See: 

http://doc.tryton.org/4.0/trytond/doc/topics/configuration.html#report 

> This will work for both tryton client (gtk and sao) as the process is 
> done on server side. 

In the config.py has this code default self.set('report', 'unoconv', 'pipe,name=trytond;urp;StarOffice.ComponentContext') this is the code in the link configuration.html is this right setup?

Then I have also set the extension to Portable Document Format, I done this through Administration > User Interface > Action > Report. is this what you are referring to [Your ir.report record must have pdf extension selected]?

Sergi Almacellas Abellana

unread,
Oct 19, 2016, 9:53:58 AM10/19/16
to try...@googlegroups.com
El 17/10/16 a les 05:05, zmers...@gmail.com ha escrit:
>> Your ir.report record must have pdf extension selected. Then tryton will
>> use unoconv [1] to convert from odt to pdf. You should configure the
>> parameters used on your config file. See:
>>
>> http://doc.tryton.org/4.0/trytond/doc/topics/configuration.html#report
> <http://www.google.com/url?q=http%3A%2F%2Fdoc.tryton.org%2F4.0%2Ftrytond%2Fdoc%2Ftopics%2Fconfiguration.html%23report&sa=D&sntz=1&usg=AFQjCNEwXhu3nIbzFqD74srKDFC7UG7yaw>
>>
>> This will work for both tryton client (gtk and sao) as the process is
>> done on server side.
>
> In the config.py has this code default self.set('report', 'unoconv',
> 'pipe,name=trytond;urp;StarOffice.ComponentContext') this is the code in
> the link configuration.html is this right setup?
>

That's the default value, you can specify on trytond.conf file another
settings if you want.

> Then I have also set the extension to Portable Document Format, I done
> this through Administration > User Interface > Action > Report. is this
> what you are referring to [Your ir.report record must have pdf extension
> selected]?
Yes, that's right.

Everything should work now, isn't it?
Reply all
Reply to author
Forward
0 new messages