This question has been flagged
6 Replies
6301 Views

Hi

How can I modify:


<div class="col-xs-3" t-if="o.date_invoice">

<strong>Datum računa:</strong>

<p t-field="o.date_invoice"/>

</div>


To display date and also time of Invoice?


I see that this in sales report shows time:


<div t-if="o.date_order" class="col-xs-3">

<strong t-if="o.state not in ['draft','sent']">Datum narudžbe:</strong>

<strong t-if="o.state in ['draft','sent']">Datum ponude:</strong>

<p t-field="o.date_order"/>

</div>

But how to do it on invoice?


Thanks

Avatar
Discard
Best Answer

You have to override the definition of the field date_invoice via Python.

date_order  is a DATETIME field - always storing the time.

date_invoice  is a DATE field - never storing the time.

(I've never seen or been asked to show a time on an Invoice by the way!)

Avatar
Discard
Author

We have to have time because of the law :)

True.. in croatia date and time is requirred to be on invoice :) amog other wierd things :)

Best Answer

This should do the job

from openerp import models, fields, api 

class override_date_invoice(models.Model):
_inherit = 'account.invoice'
date_invoice = fields.Datetime(string = 'Invoice Date', readonly = True, states = {'draft': [('readonly', False)]}, index=True,help=’Keep empty to use the current date’,copy = False)
    
Avatar
Discard
Author

HI Thanks and because I am new in all of this can you just tel me how to add this overrride in template? Thanks

You have to create a new module. https://www.odoo.com/documentation/8.0/howtos/backend.html And write my code in your modul, then install it

Author

Hi I created module but it does not add anything, is there anything else that I need to override?

It should not add something, it should only replace the field.date with a Datetime one, to add the Time also

I have just writen the modul for my system and it works without problems. The field date_invoice in custumer invoice now takes date and time. Have you installed the modul? In your _openerp_.py you have to add account as dependency

Author Best Answer

Is it possible to do is something like this and get time from invoice? To save it?


</div>

<div class="col-xs-3" t-if="o.date_invoice">

<strong>Datum računa:</strong>

<p><t t-if="o.date_invoice is not False"><t t-esc="time.strftime('%d.%m.%Y %H:%M')"/></t></p>

</div>


Avatar
Discard