PyOdoo 0.5.7__tar.gz → 0.5.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/PKG-INFO +2 -1
  2. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/PyOdoo.egg-info/PKG-INFO +2 -1
  3. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/PyOdoo.egg-info/SOURCES.txt +1 -0
  4. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/compare_type.py +10 -0
  5. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/constants.py +1 -1
  6. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/setup.cfg +1 -0
  7. PyOdoo-0.5.8/tests/test_compare_types.py +393 -0
  8. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/tests/test_contacts.py +3 -18
  9. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/LICENSE +0 -0
  10. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/PyOdoo.egg-info/dependency_links.txt +0 -0
  11. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/PyOdoo.egg-info/top_level.txt +0 -0
  12. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/README.md +0 -0
  13. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/__init__.py +0 -0
  14. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/active_status_choice.py +0 -0
  15. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/boolean_operator.py +0 -0
  16. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/filter.py +0 -0
  17. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/message_subtype.py +0 -0
  18. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/samples/__init__.py +0 -0
  19. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/samples/awaitable.py +0 -0
  20. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/samples/contacts.py +0 -0
  21. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/samples/contacts_async.py +0 -0
  22. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/v12/__init__.py +0 -0
  23. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/v12/api.py +0 -0
  24. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyodoo/v12/model.py +0 -0
  25. {PyOdoo-0.5.7 → PyOdoo-0.5.8}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOdoo
3
- Version: 0.5.7
3
+ Version: 0.5.8
4
4
  Summary: API for Odoo
5
5
  Home-page: http://www.muflone.com/pyodoo/
6
6
  Author: Fabio Castelli
@@ -13,6 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
16
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
18
  Description-Content-Type: text/markdown
18
19
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOdoo
3
- Version: 0.5.7
3
+ Version: 0.5.8
4
4
  Summary: API for Odoo
5
5
  Home-page: http://www.muflone.com/pyodoo/
6
6
  Author: Fabio Castelli
@@ -13,6 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
16
17
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
18
  Description-Content-Type: text/markdown
18
19
  License-File: LICENSE
@@ -20,4 +20,5 @@ pyodoo/samples/contacts_async.py
20
20
  pyodoo/v12/__init__.py
21
21
  pyodoo/v12/api.py
22
22
  pyodoo/v12/model.py
23
+ tests/test_compare_types.py
23
24
  tests/test_contacts.py
@@ -32,3 +32,13 @@ class CompareType(object):
32
32
  NOT_IN = 'not in'
33
33
  CONTAINS = 'ilike'
34
34
  CONTAINS_NOT = 'not ilike'
35
+ NOT_CONTAINS = 'not ilike'
36
+ LIKE = 'like'
37
+ NOT_LIKE = 'not like'
38
+ ILIKE = 'ilike'
39
+ NOT_ILIKE = 'not ilike'
40
+ RAW_LIKE = '=like'
41
+ RAW_ILIKE = '=ilike'
42
+ UNSET_OR_EQUAL = '=?'
43
+ CHILD_OF = 'child_of'
44
+ PARENT_OF = 'parent_of'
@@ -19,7 +19,7 @@
19
19
  ##
20
20
 
21
21
  APP_NAME = 'PyOdoo'
22
- APP_VERSION = '0.5.7'
22
+ APP_VERSION = '0.5.8'
23
23
  APP_DESCRIPTION = 'API for Odoo'
24
24
  APP_DOMAIN = 'pyodoo'
25
25
  APP_ID = f'{APP_DOMAIN}.muflone.com'
@@ -17,6 +17,7 @@ classifiers =
17
17
  Programming Language :: Python :: 3
18
18
  Programming Language :: Python :: 3.9
19
19
  Programming Language :: Python :: 3.10
20
+ Programming Language :: Python :: 3.11
20
21
  Topic :: Software Development :: Libraries :: Python Modules
21
22
 
22
23
  [options]
@@ -0,0 +1,393 @@
1
+ ##
2
+ # Project: PyOdoo
3
+ # Description: API for Odoo
4
+ # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
+ # Copyright: 2021-2023 Fabio Castelli
6
+ # License: GPL-3+
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
19
+ ##
20
+
21
+ import unittest
22
+
23
+ from pyodoo import CompareType, Filter
24
+
25
+ import utility
26
+
27
+
28
+ class TestCaseCompareTypes(unittest.TestCase):
29
+ @classmethod
30
+ def setUpClass(cls):
31
+ """
32
+ Model object preparation
33
+ """
34
+ cls.model = utility.get_model_from_demo(model_name='product.template')
35
+ cls.model.authenticate()
36
+
37
+ def test_01_filter_equal(self) -> None:
38
+ """
39
+ Search some rows using filters using compare EQUAL
40
+ """
41
+ filters = [Filter(field='name',
42
+ compare_type=CompareType.EQUAL,
43
+ value='Mozzarella Sandwich')]
44
+ results = self.model.search(filters=filters)
45
+ # Check if the results are not None
46
+ self.assertIsNotNone(results)
47
+ # Check if the results list has exactly one item
48
+ self.assertEqual(len(results), 1)
49
+ # Check if the results list contains the Mozzarella Sandwich
50
+ self.assertIn(75, results)
51
+
52
+ def test_02_filter_not_equal(self) -> None:
53
+ """
54
+ Search some rows using filters using compare NOT_EQUAL
55
+ """
56
+ filters = [Filter(field='name',
57
+ compare_type=CompareType.CONTAINS,
58
+ value='Sandwich'),
59
+ Filter(field='name',
60
+ compare_type=CompareType.NOT_EQUAL,
61
+ value='Mozzarella Sandwich')]
62
+ results = self.model.search(filters=filters)
63
+ # Check if the results are not None
64
+ self.assertIsNotNone(results)
65
+ # Check if the results list has exactly three items
66
+ self.assertEqual(len(results), 3)
67
+ # Check if the results list doesn't contain the Mozzarella Sandwich
68
+ self.assertNotIn(75, results)
69
+
70
+ def test_03_filter_greater(self) -> None:
71
+ """
72
+ Search some rows using filters using compare GREATER
73
+ """
74
+ filters = [Filter(field='name',
75
+ compare_type=CompareType.CONTAINS,
76
+ value='Sandwich'),
77
+ Filter(field='name',
78
+ compare_type=CompareType.GREATER,
79
+ value='Mozzarella Sandwich')]
80
+ results = self.model.search(filters=filters)
81
+ # Check if the results are not None
82
+ self.assertIsNotNone(results)
83
+ # Check if the results list has exactly one item
84
+ self.assertEqual(len(results), 1)
85
+ # Check if the results list doesn't contain the Mozzarella Sandwich
86
+ self.assertNotIn(75, results)
87
+
88
+ def test_04_filter_greater_equal(self) -> None:
89
+ """
90
+ Search some rows using filters using compare GREATER_EQ
91
+ """
92
+ filters = [Filter(field='name',
93
+ compare_type=CompareType.CONTAINS,
94
+ value='Sandwich'),
95
+ Filter(field='name',
96
+ compare_type=CompareType.GREATER_EQ,
97
+ value='Mozzarella Sandwich')]
98
+ results = self.model.search(filters=filters)
99
+ # Check if the results are not None
100
+ self.assertIsNotNone(results)
101
+ # Check if the results list has exactly two items
102
+ self.assertEqual(len(results), 2)
103
+ # Check if the results list contains the Mozzarella Sandwich
104
+ self.assertIn(75, results)
105
+
106
+ def test_05_filter_lower(self) -> None:
107
+ """
108
+ Search some rows using filters using compare LOWER
109
+ """
110
+ filters = [Filter(field='name',
111
+ compare_type=CompareType.CONTAINS,
112
+ value='Sandwich'),
113
+ Filter(field='name',
114
+ compare_type=CompareType.LOWER,
115
+ value='Mozzarella Sandwich')]
116
+ results = self.model.search(filters=filters)
117
+ # Check if the results are not None
118
+ self.assertIsNotNone(results)
119
+ # Check if the results list has exactly two items
120
+ self.assertEqual(len(results), 2)
121
+ # Check if the results list doesn't contain the Mozzarella Sandwich
122
+ self.assertNotIn(75, results)
123
+
124
+ def test_06_filter_lower_equal(self) -> None:
125
+ """
126
+ Search some rows using filters using compare LOWER_EQ
127
+ """
128
+ filters = [Filter(field='name',
129
+ compare_type=CompareType.CONTAINS,
130
+ value='Sandwich'),
131
+ Filter(field='name',
132
+ compare_type=CompareType.LOWER_EQ,
133
+ value='Mozzarella Sandwich')]
134
+ results = self.model.search(filters=filters)
135
+ # Check if the results are not None
136
+ self.assertIsNotNone(results)
137
+ # Check if the results list has exactly three items
138
+ self.assertEqual(len(results), 3)
139
+ # Check if the results list contains the Mozzarella Sandwich
140
+ self.assertIn(75, results)
141
+
142
+ def test_07_filter_in(self) -> None:
143
+ """
144
+ Search some rows using filters using compare IN
145
+ """
146
+ filters = [Filter(field='name',
147
+ compare_type=CompareType.CONTAINS,
148
+ value='Sandwich'),
149
+ Filter(field='name',
150
+ compare_type=CompareType.IN,
151
+ value=('Club Sandwich', 'Mozzarella Sandwich'))]
152
+ results = self.model.search(filters=filters)
153
+ # Check if the results are not None
154
+ self.assertIsNotNone(results)
155
+ # Check if the results list has exactly two items
156
+ self.assertEqual(len(results), 2)
157
+ # Check if the results list contains the Club Sandwich
158
+ self.assertIn(76, results)
159
+ # Check if the results list contains the Mozzarella Sandwich
160
+ self.assertIn(75, results)
161
+
162
+ def test_08_filter_not_in(self) -> None:
163
+ """
164
+ Search some rows using filters using compare NOT_IN
165
+ """
166
+ filters = [Filter(field='name',
167
+ compare_type=CompareType.CONTAINS,
168
+ value='Sandwich'),
169
+ Filter(field='name',
170
+ compare_type=CompareType.NOT_IN,
171
+ value=('Club Sandwich', 'Mozzarella Sandwich'))]
172
+ results = self.model.search(filters=filters)
173
+ # Check if the results are not None
174
+ self.assertIsNotNone(results)
175
+ # Check if the results list has exactly two items
176
+ self.assertEqual(len(results), 2)
177
+ # Check if the results list doesn't contain the Club Sandwich
178
+ self.assertNotIn(76, results)
179
+ # Check if the results list doesn't contain the Mozzarella Sandwich
180
+ self.assertNotIn(75, results)
181
+
182
+ def test_09_filter_contains(self) -> None:
183
+ """
184
+ Search some rows using filters using compare CONTAINS
185
+ """
186
+ filters = [Filter(field='name',
187
+ compare_type=CompareType.CONTAINS,
188
+ value='Sandwich')]
189
+ results = self.model.search(filters=filters)
190
+ # Check if the results are not None
191
+ self.assertIsNotNone(results)
192
+ # Check if the results list has exactly four items
193
+ self.assertEqual(len(results), 4)
194
+ # Check if the results list contains the Mozzarella Sandwich
195
+ self.assertIn(75, results)
196
+
197
+ def test_10_filter_contains_not(self) -> None:
198
+ """
199
+ Search some rows using filters using compare CONTAINS_NOT
200
+ """
201
+ filters = [Filter(field='name',
202
+ compare_type=CompareType.CONTAINS,
203
+ value='Sandwich'),
204
+ Filter(field='name',
205
+ compare_type=CompareType.CONTAINS_NOT,
206
+ value='mozzarella')]
207
+ results = self.model.search(filters=filters)
208
+ # Check if the results are not None
209
+ self.assertIsNotNone(results)
210
+ # Check if the results list has exactly three items
211
+ self.assertEqual(len(results), 3)
212
+ # Check if the results list doesn't contain the Mozzarella Sandwich
213
+ self.assertNotIn(75, results)
214
+
215
+ def test_11_filter_not_contains(self) -> None:
216
+ """
217
+ Search some rows using filters using compare NOT_CONTAINS
218
+ """
219
+ filters = [Filter(field='name',
220
+ compare_type=CompareType.CONTAINS,
221
+ value='Sandwich'),
222
+ Filter(field='name',
223
+ compare_type=CompareType.NOT_CONTAINS,
224
+ value='mozzarella')]
225
+ results = self.model.search(filters=filters)
226
+ # Check if the results are not None
227
+ self.assertIsNotNone(results)
228
+ # Check if the results list has exactly three items
229
+ self.assertEqual(len(results), 3)
230
+ # Check if the results list doesn't contain the Mozzarella Sandwich
231
+ self.assertNotIn(75, results)
232
+
233
+ def test_12_filter_like(self) -> None:
234
+ """
235
+ Search some rows using filters using compare LIKE
236
+ """
237
+ filters = [Filter(field='name',
238
+ compare_type=CompareType.CONTAINS,
239
+ value='Sandwich'),
240
+ Filter(field='name',
241
+ compare_type=CompareType.LIKE,
242
+ value='Mozzarella')]
243
+ results = self.model.search(filters=filters)
244
+ # Check if the results are not None
245
+ self.assertIsNotNone(results)
246
+ # Check if the results list has exactly one item
247
+ self.assertEqual(len(results), 1)
248
+ # Check if the results list contains the Mozzarella Sandwich
249
+ self.assertIn(75, results)
250
+
251
+ def test_13_filter_not_like(self) -> None:
252
+ """
253
+ Search some rows using filters using compare NOT_LIKE
254
+ """
255
+ filters = [Filter(field='name',
256
+ compare_type=CompareType.CONTAINS,
257
+ value='Sandwich'),
258
+ Filter(field='name',
259
+ compare_type=CompareType.NOT_LIKE,
260
+ value='Mozzarella')]
261
+ results = self.model.search(filters=filters)
262
+ # Check if the results are not None
263
+ self.assertIsNotNone(results)
264
+ # Check if the results list has exactly three items
265
+ self.assertEqual(len(results), 3)
266
+ # Check if the results list doesn't contain the Mozzarella Sandwich
267
+ self.assertNotIn(75, results)
268
+
269
+ def test_14_filter_ilike(self) -> None:
270
+ """
271
+ Search some rows using filters using compare ILIKE
272
+ """
273
+ filters = [Filter(field='name',
274
+ compare_type=CompareType.CONTAINS,
275
+ value='Sandwich'),
276
+ Filter(field='name',
277
+ compare_type=CompareType.ILIKE,
278
+ value='mozzarella')]
279
+ results = self.model.search(filters=filters)
280
+ # Check if the results are not None
281
+ self.assertIsNotNone(results)
282
+ # Check if the results list has exactly one item
283
+ self.assertEqual(len(results), 1)
284
+ # Check if the results list contains the Mozzarella Sandwich
285
+ self.assertIn(75, results)
286
+
287
+ def test_15_filter_not_ilike(self) -> None:
288
+ """
289
+ Search some rows using filters using compare NOT_ILIKE
290
+ """
291
+ filters = [Filter(field='name',
292
+ compare_type=CompareType.CONTAINS,
293
+ value='Sandwich'),
294
+ Filter(field='name',
295
+ compare_type=CompareType.NOT_ILIKE,
296
+ value='mozzarella')]
297
+ results = self.model.search(filters=filters)
298
+ # Check if the results are not None
299
+ self.assertIsNotNone(results)
300
+ # Check if the results list has exactly three items
301
+ self.assertEqual(len(results), 3)
302
+ # Check if the results list doesn't contain the Mozzarella Sandwich
303
+ self.assertNotIn(75, results)
304
+
305
+ def test_16_filter_raw_like(self) -> None:
306
+ """
307
+ Search some rows using filters using compare RAW_LIKE
308
+ """
309
+ filters = [Filter(field='name',
310
+ compare_type=CompareType.CONTAINS,
311
+ value='Sandwich'),
312
+ Filter(field='name',
313
+ compare_type=CompareType.RAW_LIKE,
314
+ value='Mozzarella %')]
315
+ results = self.model.search(filters=filters)
316
+ # Check if the results are not None
317
+ self.assertIsNotNone(results)
318
+ # Check if the results list has exactly one item
319
+ self.assertEqual(len(results), 1)
320
+ # Check if the results list contains the Mozzarella Sandwich
321
+ self.assertIn(75, results)
322
+
323
+ def test_17_filter_raw_ilike(self) -> None:
324
+ """
325
+ Search some rows using filters using compare RAW_ILIKE
326
+ """
327
+ filters = [Filter(field='name',
328
+ compare_type=CompareType.CONTAINS,
329
+ value='Sandwich'),
330
+ Filter(field='name',
331
+ compare_type=CompareType.RAW_ILIKE,
332
+ value='mozzarella %')]
333
+ results = self.model.search(filters=filters)
334
+ # Check if the results are not None
335
+ self.assertIsNotNone(results)
336
+ # Check if the results list has exactly one item
337
+ self.assertEqual(len(results), 1)
338
+ # Check if the results list contains the Mozzarella Sandwich
339
+ self.assertIn(75, results)
340
+
341
+ def test_18_filter_unset_or_equal(self) -> None:
342
+ """
343
+ Search some rows using filters using compare UNSET_OR_EQUAL
344
+ """
345
+ filters = [Filter(field='name',
346
+ compare_type=CompareType.CONTAINS,
347
+ value='Sandwich'),
348
+ Filter(field='uom_id',
349
+ compare_type=CompareType.UNSET_OR_EQUAL,
350
+ value=1)]
351
+ results = self.model.search(filters=filters)
352
+ # Check if the results are not None
353
+ self.assertIsNotNone(results)
354
+ # Check if the results list has exactly four items
355
+ self.assertEqual(len(results), 4)
356
+ # Check if the results list contains the Mozzarella Sandwich
357
+ self.assertIn(75, results)
358
+
359
+ def test_19_filter_child_of(self) -> None:
360
+ """
361
+ Search some rows using filters using compare CHILD_OF
362
+ """
363
+ filters = [Filter(field='name',
364
+ compare_type=CompareType.CONTAINS,
365
+ value='Sandwich'),
366
+ Filter(field='categ_id',
367
+ compare_type=CompareType.CHILD_OF,
368
+ value='PoS')]
369
+ results = self.model.search(filters=filters)
370
+ # Check if the results are not None
371
+ self.assertIsNotNone(results)
372
+ # Check if the results list has exactly four items
373
+ self.assertEqual(len(results), 4)
374
+ # Check if the results list contains the Mozzarella Sandwich
375
+ self.assertIn(75, results)
376
+
377
+ def test_20_filter_parent_of(self) -> None:
378
+ """
379
+ Search some rows using filters using compare PARENT_OF
380
+ """
381
+ filters = [Filter(field='name',
382
+ compare_type=CompareType.CONTAINS,
383
+ value='Sandwich'),
384
+ Filter(field='categ_id',
385
+ compare_type=CompareType.PARENT_OF,
386
+ value='Food')]
387
+ results = self.model.search(filters=filters)
388
+ # Check if the results are not None
389
+ self.assertIsNotNone(results)
390
+ # Check if the results list has exactly four items
391
+ self.assertEqual(len(results), 4)
392
+ # Check if the results list contains the Mozzarella Sandwich
393
+ self.assertIn(75, results)
@@ -29,6 +29,8 @@ from pyodoo import (ActiveStatusChoice,
29
29
  from pyodoo.constants import APP_AUTHOR_EMAIL, APP_NAME, APP_VERSION
30
30
  from pyodoo.v12 import Model
31
31
 
32
+ import utility
33
+
32
34
 
33
35
  class TestCaseContacts(unittest.TestCase):
34
36
  @classmethod
@@ -36,24 +38,7 @@ class TestCaseContacts(unittest.TestCase):
36
38
  """
37
39
  Model object preparation
38
40
  """
39
- # Get the free public server credentials
40
- try:
41
- info = xmlrpc.client.ServerProxy(
42
- uri='https://demo.odoo.com/start').start()
43
- except xmlrpc.client.Fault:
44
- # Sometimes the free public server start page is not available
45
- # Use a specif instance (this may be very mutable)
46
- info = {'host': 'https://demo4.odoo.com',
47
- 'database': 'demo_160_1676157153',
48
- 'user': 'admin',
49
- 'password': 'admin'}
50
- cls.model = Model(model_name='res.partner',
51
- endpoint=info['host'],
52
- database=info['database'],
53
- username=info['user'],
54
- password=info['password'],
55
- language='en_US',
56
- authenticate=False)
41
+ cls.model = utility.get_model_from_demo(model_name='res.partner')
57
42
 
58
43
  def test_01_authenticate(self) -> None:
59
44
  """
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes