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

web service search arguments

By
peterm
on 2/26/13, 10:20 AM 1,297 views

I'm trying to retrieve some calendar entries. With the following code I get always all entries with category id 12. The date is not used.

What would be the right syntax ?

dt = datetime.now()
args = [('categ_id','=',12),('date','=',str(dt))]
ids = sock.execute(dbname, uid, pwd, 'crm.meeting', 'search', args)

Update

Thanks so far but it won't:

Database:
test=# select * from crm_meeting where date='2013-03-25 00:00:00';
-[ RECORD 1 ]----------+---------------------------
id                     | 663
create_uid             | 1
create_date            | 2013-03-25 11:32:19.318743
end_type               | forever
date                   | 2013-03-25 00:00:00
freq                   | None
categ_id               | 17
class                  | public

Python:
dt = datetime.now().strftime("%Y-%m-%d 00:00:00")
print dt
args = [('categ_id','=',17),('date','=',dt)]
ids = sock.execute(dbname, uid, pwd, 'crm.meeting', 'search', args)

print ids

Output:

2013-03-25 00:00:00
[864, 863, 862, 861, 860, 859, 858, 857, 856, 855, ...

still getting all entries with categorie id 17 ...

1

Andreas Brueckl

--Andreas Brueckl--
5056
| 7 8 7
Vienna, Austria
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl
On 3/22/13, 8:46 PM

The field date of model crm.meeting is a timestamp. You can use the following script:

import datetime
date_from = datetime.datetime.now().strftime("%Y-%m-%d 00:00:00")
date_to = datetime.datetime.now().strftime("%Y-%m-%d 23:59:59")
args = [('categ_id','=',12),('date','>=',date_from), ('date','<=',date_to)]
ids = sock.execute(dbname, uid, pwd, 'crm.meeting', 'search', args)

see my update

peterm
on 3/25/13, 7:56 AM
0

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 3/22/13, 2:08 PM

This work:

import datetime
dt = datetime.datetime.today()
args = [('categ_id','=',12),('date','=',str(dt)]
ids = sock.execute(dbname, uid, pwd, 'crm.meeting', 'search', args)

?

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

0 follower(s)

Stats

Asked: 2/26/13, 10:20 AM
Seen: 1297 times
Last updated: 3/16/15, 8:10 AM