Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to execute a python function after creation of a custom report.

By
Pieter Paulussen
on 5/17/16, 6:11 AM 304 views

I have a report that generates product labels for a certain recordset. How can I call a python function from my custom module before/after the report has been generated? 

0
Pieter Paulussen
On 5/17/16, 7:32 AM

To answer my own question. Say I want to keep track when a certain record is printed or not:

You can define a new function in the model's .py file:

def set_record_printed(self):
    self.ensure_one()
self.printed = True
self.timestamp_printed = fields.Datetime.now()

Where self will be the record on which you want to execute the function.

Then in the report QWeb template just call that function on each record.

<t t-esc="product.set_record_printed()"/>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/17/16, 6:11 AM
Seen: 304 times
Last updated: 5/17/16, 7:42 AM