Odoo Help


how to write a function in Odoo 9 date field?

on 4/6/16, 11:20 AM 2,534 views

my date fields is 

salesorder_date = fields.Date('Confirm Sale Date',compute="_currentdate" store=True)
and the method for that is
def _confirmSale(self):
It is not showing the current date not even the date field in the template also.I want to append current date in this date field automatically and
of course can edit the date.

Thanks Jignesh

on 4/7/16, 2:21 PM

Jignesh Mehta

--Jignesh Mehta--
| 6 5 8
Surat, India
--Jignesh Mehta--

- I have 3+ years of Industry Experience, specializing Odoo Development, Analysis, Customization, Implementation, Integration.
- I have done many Customization modules in Sale, Purchase, Point of Sale, Inventory, CRM and much more. Also Worked in the Odoo Themes like Business Theme or E-Commerce Theme.
- Develop Jewelery Manufacturing process from Scratch. It have more than 10 Department. Develop PDF and Excel reports for this project around 150 per format.

Jignesh Mehta
On 4/7/16, 12:11 AM

Hello Paramita,

Try this :-

saleorder_date = fields.Date('Confirm Sale Date', default=fields.datetime.now())

Hope you will put this field in the xml file and no need to write method for current date. Just give default value to field.

Hope it works for you.



Damien Bouvy (dbo)

--Damien Bouvy (dbo)--

| 1 0 1
Grand-Rosière, Belgium
--Damien Bouvy (dbo)--

Damien is part of the Odoo R&D department. He has taken part in the development of several features in Odoo, including the Subscription application, the Sales application, the frontend portal and the payment acquirers.

Nowadays he commits on our internal codebase, maintaining the billing process of Odoo.com, developing external tools and internal processes. More recently, he took part in the development of the Odoo.sh platform.

Damien Bouvy (dbo)
On 4/8/16, 10:00 AM

Since this uses the @api.multi decorator, it would be wiser to do something like

def _confirmSale(self):
    for order in self:
        order.salesorder_date = fields.Date.today() # there's a today() helper on the Date field

But since there is no @api.depends on this method, this value will be computed once at the creation of the record then never changed; and it's probably not what you want. BTW, the compute attribute on the field should be the name of the method.

What are you trying to do exactly?

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

2 follower(s)


Asked: 4/6/16, 11:20 AM
Seen: 2534 times
Last updated: 8/16/16, 7:54 AM