-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7_push_notification.py
More file actions
59 lines (49 loc) · 2.46 KB
/
7_push_notification.py
File metadata and controls
59 lines (49 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
import xmlrpc.client
from _odoo_conf import get_odoo_config
odoo_info = get_odoo_config()
url = odoo_info.get('server')
db = odoo_info.get('dbname')
username = odoo_info.get('username')
password = odoo_info.get('pwd')
login = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = login.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
# search_read all
all_notify = models.execute_kw(db, uid, password, 'vti.notification', 'search_read',
[], {
'fields': [
'title',
'push_time',
'content'
]
})
# search_read by notify id
notify_by_id = models.execute_kw(db, uid, password, 'vti.notification', 'search_read',
[[('id', '=', 89)]], {
'fields': [
'title',
'push_time',
'content'
]
})
# get department id
department_id = models.execute_kw(db, uid, password, 'hr.department', 'search', [[('name', '=', 'VTI.D4')]])
# get departments ids
department_ids = models.execute_kw(db, uid, password, 'hr.department', 'search',
[[('name', 'in', ['VTI.D4', 'VTI.D5'])]])
# search_read notify by departments ids and status sent
notify_by_departments = models.execute_kw(db, uid, password, 'vti.notification', 'search_read',
[[
'|',
('department_ids', 'in', department_ids),
('department_ids', '=', False),
('state', '=', 'sent')
]], {
'fields': [
'title',
'push_time',
'content'],
'limit': 20, 'order': 'id desc'
})
print(notify_by_id)