Scarlett stone
Scarlett stone

Reputation: 225

Odoo 8, get error 'datestyle' setting

last night I was trying to learn about odoo and I was trying to get a date. I was successful at getting a date from another model and also I was trying to convert the date from %d/%m/%Y to %Y-%m-%d. But when I try to save it, The error occurs. I'll show my code and my error.

My code :

date_values = fields.Date(
    string='Tax Date',
    required=True,
)

new = datetime.datetime.strptime(get_date_from_another_model, "%d/%m/%Y").strftime("%Y-%m-%d")
self.date_values = new

Error :

DataError: date/time field value out of range: "23/08/2017"
LINE 1: ...iod August 2017', 'Faktur Pajak Normal', 4600000, '23/08/201...
                                                             ^
HINT:  Perhaps you need a different "datestyle" setting.

I was trying to find a similar question like this, I did find some question like this, but the answer is always talking about setting on postgresql, I think my postgresql is ok, but i think something is wrong with my code. I don't know, I hope someone can help me.

Upvotes: 1

Views: 1238

Answers (1)

Lakshminarayanan
Lakshminarayanan

Reputation: 320

date_from = fields.Date(string='From date', required=True,default=lambda *a: time.strftime('%Y-%m-%d'))

did you tried this

Upvotes: 1

Related Questions