Odoo Help


How to edit a record when user press the print button

willie ho
on 1/14/15, 4:31 AM 778 views

I want to add a printing time to the record when the user print the document

what should I do?

You don't have to modify any record? Just modify the QWeb report to print a date with time in place of just the date for example?

on 1/14/15, 4:52 AM

Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 5 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 1/14/15, 5:14 AM

You can call the button using type="object" and do your function then return the print format.

There is a similar scenario @ Sales module (https://github.com/odoo/odoo/blob/8.0/addons/sale/sale.py#L439).
     def print_quotation(self, cr, uid, ids, context=None):
        This function prints the sales order and mark it as sent, so that we can see more easily the next step of the workflow
        assert len(ids) == 1, 'This option should only be used for a single id at a time'
        self.signal_workflow(cr, uid, ids, 'quotation_sent')
        return self.pool['report'].get_action(cr, uid, ids, 'sale.report_saleorder', context=context)




| 5 3 8
Pondicherry, India
On 1/14/15, 5:04 AM

Hi willie ho,

If that is mako report means,use " ${time.strftime(time.ctime())} "in the code or if it is rml report ,use [[ time.strftime(time.ctime())]] in the code.The answer is in this format "Wed Jan 14 09:55:57 2015.

To get the cuttent time value in the code,you can use "DATETIME.DATETIME.NOW()" function in the method. (Note: It calls the __init__ method first when we click print button.You can write a method for the field in that)

I hope it should work..

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 1/14/15, 4:31 AM
Seen: 778 times
Last updated: 3/16/15, 8:10 AM