Odoo Help

Welcome!

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

0

odoo 8 search condition using date error

By
George
on 5/26/16, 11:26 AM 301 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
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

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

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())

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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