Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4988 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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)
Awatar
Odrzuć
Autor

see my update

Najlepsza odpowiedź

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)

?

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
sty 24
38707
1
mar 15
5861
1
mar 15
4495
0
mar 15
4206
0
mar 15
3652