Override Print button

Using the built-in report builder, some how doesn’t really fit to the requirement from my boss. I plan to use external lib to access data from tables and produce an excel file.

Currently, when I click on Print button (see pic), I can see that my custom report (created using built-in builder) is listed there.

The data that shows just below the button is from UserTimesheet model, while the list (Records) are from UserTimesheetRecord model.

Is there anyway I can override this button to execute custom method?
If yes.. where should I write this method? should I override that in UserTimesheet model?

Is there a sample code for overriding a button? It would help a lot..

Thanks in advance
Bromo

You need to create a custom python class with a __name__ that matches the report name of your report. (This is explained in the report documentation) Then the tryton server will get that class from the pool and call the execute method function in order to get the report.

You can override any of the functions of the report api to match your needs.

Hope this helps!

1 Like

Hi @pokoli

I following your advice.. currently I am exploring using libre office way.
And I learn from the opportunity tutorial.

So I create the fodt file and follow all the codes, and I can see my report registered in the tryton dashboard.

But after I print it, and downloaded, the content of downloaded odt file is looks like the template, and the place-holder are not populated, and no errors printed in the console.

I already install the LibreOffice in my server too. Any advice?

Bromo

The tutorial is a bad example, that’s not how it works. Take a look at the Invoice template or the Sale order template

In both templates you see that you have to insert the different placeholders. I’m using Libreoffice 25.2.3.1 and there I have to go to InsertFieldMore fields. Then in the dialog select the tab named Functions. Select in the left column called Type the Placeholder and in the middle column Text. In the right column you can enter the different statements. But I suggest to take a look at the templates named above.

1 Like

Hi @edbo

Actually I am required to produce Spreadsheet in my current project,
The samples u gave (Invoice & Sell Order Template) are producing document type. Can u show me a link to create template in Libre for Spreadsheet template (excel kind)?

Thank you in advance
Bromo

Tryton is using Relatorio as templating library. See Tryton / Relatorio · GitLab and Relatorio — A templating library able to output odt and pdf files. Take a look at the indepth Example where also a spreadsheet example is shown. The ods files can be downloaded from the first link.