Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3369 Visualizzazioni

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

what should I do?

Avatar
Abbandona

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?

Risposta migliore

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)

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona