Odoo Help

0

odoo 8 search condition using date error

By
George Vincent
on 5/26/16, 11:26 AM 617 views

Hi  all,

          I am trying to retrieve some values that matches date but i am getting error. 

I created like this self.search([('date', '=', datetime.now().date())])


 ERROR  openerp.sql_db: Programming error: COALESCE types text and date cannot be matched

LINE 2: ... SELECT ct.id, coalesce(it.value,ct."date")

^

, in query SELECT "table_table".id FROM "table_table" WHERE ("table_table"."id" in (WITH temp_irt_current (id, name) as (

SELECT ct.id, coalesce(it.value,ct."date")

FROM bill_records ct

LEFT JOIN ir_translation it ON (it.name = %s and

it.lang = %s and

it.type = %s and

it.res_id = ct.id and

it.value != '')

)

SELECT id FROM temp_irt_current WHERE name = %s order by name

)) ORDER BY "table_table"."id"  

0
George Vincent
On 5/26/16, 1:51 PM

Hi friend,

                I tried like you said but i am getting the same 

               self.search([('date', '=', fields.Date.to_string(datetime.today().date()))])

              Sample out put from your code 

                      print fields.Date.to_string(datetime.today().date())         -----------2016-05-26

                      print type(fields.Date.to_string(datetime.today().date())) ---------<type 'str'>


0
Prakash Sharma
On 5/26/16, 1:04 PM

As odoo store date in text format so convert type of date to string using  strftime  or use  fields.Date.to_string(datetime.datetime.today())

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.

Register

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

1 follower(s)

Stats

Asked: 5/26/16, 11:26 AM
Seen: 617 times
Last updated: 5/26/16, 1:51 PM