PyOdoo 0.6.0__tar.gz → 0.7.1__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 (33) hide show
  1. {PyOdoo-0.6.0 → pyodoo-0.7.1}/PKG-INFO +5 -2
  2. {PyOdoo-0.6.0 → pyodoo-0.7.1}/PyOdoo.egg-info/PKG-INFO +5 -2
  3. {PyOdoo-0.6.0 → pyodoo-0.7.1}/PyOdoo.egg-info/SOURCES.txt +3 -0
  4. pyodoo-0.7.1/PyOdoo.egg-info/requires.txt +2 -0
  5. {PyOdoo-0.6.0 → pyodoo-0.7.1}/README.md +1 -1
  6. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/__init__.py +1 -1
  7. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/active_status_choice.py +1 -1
  8. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/boolean_operator.py +1 -1
  9. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/compare_type.py +1 -1
  10. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/constants.py +3 -3
  11. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/filter.py +1 -1
  12. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/message_subtype.py +1 -1
  13. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/samples/awaitable.py +1 -1
  14. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/samples/contacts.py +1 -1
  15. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/samples/contacts_async.py +1 -1
  16. pyodoo-0.7.1/pyodoo/samples/python_code.py +52 -0
  17. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/samples/sql_excel_query.py +1 -1
  18. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/v12/__init__.py +2 -1
  19. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/v12/api.py +1 -1
  20. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/v12/model.py +1 -1
  21. pyodoo-0.7.1/pyodoo/v12/python_code.py +157 -0
  22. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/v12/sql_excel_query.py +1 -1
  23. {PyOdoo-0.6.0 → pyodoo-0.7.1}/setup.cfg +2 -0
  24. {PyOdoo-0.6.0 → pyodoo-0.7.1}/tests/test_compare_types.py +23 -23
  25. {PyOdoo-0.6.0 → pyodoo-0.7.1}/tests/test_contacts.py +3 -3
  26. pyodoo-0.7.1/tests/test_python_code.py +125 -0
  27. {PyOdoo-0.6.0 → pyodoo-0.7.1}/tests/test_sql_excel_query.py +1 -1
  28. PyOdoo-0.6.0/PyOdoo.egg-info/requires.txt +0 -1
  29. {PyOdoo-0.6.0 → pyodoo-0.7.1}/LICENSE +0 -0
  30. {PyOdoo-0.6.0 → pyodoo-0.7.1}/PyOdoo.egg-info/dependency_links.txt +0 -0
  31. {PyOdoo-0.6.0 → pyodoo-0.7.1}/PyOdoo.egg-info/top_level.txt +0 -0
  32. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyodoo/samples/__init__.py +0 -0
  33. {PyOdoo-0.6.0 → pyodoo-0.7.1}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOdoo
3
- Version: 0.6.0
3
+ Version: 0.7.1
4
4
  Summary: API for Odoo
5
5
  Home-page: http://www.muflone.com/pyodoo/
6
6
  Author: Fabio Castelli
@@ -14,9 +14,12 @@ Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
19
  Description-Content-Type: text/markdown
19
20
  License-File: LICENSE
21
+ Requires-Dist: xlrd==2.0.1
22
+ Requires-Dist: requests==2.32.3
20
23
 
21
24
  # PyOdoo
22
25
 
@@ -27,7 +30,7 @@ License-File: LICENSE
27
30
 
28
31
  **Description:** API for Odoo
29
32
 
30
- **Copyright:** 2021-2023 Fabio Castelli (Muflone) <muflone@muflone.com>
33
+ **Copyright:** 2021-2024 Fabio Castelli (Muflone) <muflone@muflone.com>
31
34
 
32
35
  **License:** GPL-3+
33
36
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOdoo
3
- Version: 0.6.0
3
+ Version: 0.7.1
4
4
  Summary: API for Odoo
5
5
  Home-page: http://www.muflone.com/pyodoo/
6
6
  Author: Fabio Castelli
@@ -14,9 +14,12 @@ Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
17
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
19
  Description-Content-Type: text/markdown
19
20
  License-File: LICENSE
21
+ Requires-Dist: xlrd==2.0.1
22
+ Requires-Dist: requests==2.32.3
20
23
 
21
24
  # PyOdoo
22
25
 
@@ -27,7 +30,7 @@ License-File: LICENSE
27
30
 
28
31
  **Description:** API for Odoo
29
32
 
30
- **Copyright:** 2021-2023 Fabio Castelli (Muflone) <muflone@muflone.com>
33
+ **Copyright:** 2021-2024 Fabio Castelli (Muflone) <muflone@muflone.com>
31
34
 
32
35
  **License:** GPL-3+
33
36
 
@@ -18,11 +18,14 @@ pyodoo/samples/__init__.py
18
18
  pyodoo/samples/awaitable.py
19
19
  pyodoo/samples/contacts.py
20
20
  pyodoo/samples/contacts_async.py
21
+ pyodoo/samples/python_code.py
21
22
  pyodoo/samples/sql_excel_query.py
22
23
  pyodoo/v12/__init__.py
23
24
  pyodoo/v12/api.py
24
25
  pyodoo/v12/model.py
26
+ pyodoo/v12/python_code.py
25
27
  pyodoo/v12/sql_excel_query.py
26
28
  tests/test_compare_types.py
27
29
  tests/test_contacts.py
30
+ tests/test_python_code.py
28
31
  tests/test_sql_excel_query.py
@@ -0,0 +1,2 @@
1
+ xlrd==2.0.1
2
+ requests==2.32.3
@@ -7,7 +7,7 @@
7
7
 
8
8
  **Description:** API for Odoo
9
9
 
10
- **Copyright:** 2021-2023 Fabio Castelli (Muflone) <muflone@muflone.com>
10
+ **Copyright:** 2021-2024 Fabio Castelli (Muflone) <muflone@muflone.com>
11
11
 
12
12
  **License:** GPL-3+
13
13
 
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -19,13 +19,13 @@
19
19
  ##
20
20
 
21
21
  APP_NAME = 'PyOdoo'
22
- APP_VERSION = '0.6.0'
22
+ APP_VERSION = '0.7.1'
23
23
  APP_DESCRIPTION = 'API for Odoo'
24
24
  APP_DOMAIN = 'pyodoo'
25
25
  APP_ID = f'{APP_DOMAIN}.muflone.com'
26
26
  APP_AUTHOR = 'Fabio Castelli'
27
27
  APP_AUTHOR_EMAIL = 'muflone@muflone.com'
28
- APP_COPYRIGHT = f'Copyright 2021-2023 {APP_AUTHOR}'
28
+ APP_COPYRIGHT = f'Copyright 2021-2024 {APP_AUTHOR}'
29
29
  URL_AUTHOR = 'http://www.muflone.com/'
30
30
  URL_APPLICATION = f'{URL_AUTHOR}{APP_DOMAIN}/'
31
31
  URL_SOURCES = f'https://github.com/muflone/{APP_DOMAIN}/'
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -0,0 +1,52 @@
1
+ ##
2
+ # Project: PyOdoo
3
+ # Description: API for Odoo
4
+ # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
+ # Copyright: 2021-2024 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 os
22
+
23
+ from pyodoo.v12 import PythonCode
24
+
25
+
26
+ # Check Python Code availability
27
+ print(PythonCode.is_available(endpoint=os.environ['ODOO_ENDPOINT'],
28
+ database=os.environ['ODOO_DATABASE'],
29
+ username=os.environ['ODOO_USERNAME'],
30
+ password=os.environ['ODOO_PASSWORD'],
31
+ language=None))
32
+ # Instance Python Code object
33
+ script = PythonCode(name='test script 1',
34
+ endpoint=os.environ['ODOO_ENDPOINT'],
35
+ database=os.environ['ODOO_DATABASE'],
36
+ username=os.environ['ODOO_USERNAME'],
37
+ password=os.environ['ODOO_PASSWORD'],
38
+ language=None)
39
+
40
+ # Get Python Code ID
41
+ print(script.id)
42
+
43
+ # Set Python Code text
44
+ print(script.set_code(text='import sys\nresult = sys.version'))
45
+
46
+ # Execute the Python code and get result
47
+ script.execute()
48
+ data = script.get_result()
49
+ print(data)
50
+
51
+ # Delete Python Code object
52
+ print(script.delete())
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -20,4 +20,5 @@
20
20
 
21
21
  from .api import Api # noqa: F401
22
22
  from .model import Model # noqa: F401
23
+ from .python_code import PythonCode # noqa: F401
23
24
  from .sql_excel_query import SqlExcelQuery # noqa: F401
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -0,0 +1,157 @@
1
+ ##
2
+ # Project: PyOdoo
3
+ # Description: API for Odoo
4
+ # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
+ # Copyright: 2021-2024 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
+ from typing import Optional
22
+
23
+ import pyodoo
24
+ from pyodoo.v12.model import Model
25
+
26
+
27
+ class PythonCode(object):
28
+ """
29
+ Python Code to execute a Python code
30
+ """
31
+ def __init__(self,
32
+ name: str,
33
+ endpoint: str,
34
+ database: str,
35
+ username: str,
36
+ password: str,
37
+ language: str):
38
+ # Model object
39
+ self._code_name = name
40
+ self.model = Model(model_name='execute.python.code',
41
+ endpoint=endpoint,
42
+ database=database,
43
+ username=username,
44
+ password=password,
45
+ language=language,
46
+ authenticate=True)
47
+ # Get or create the Python Code object
48
+ results = self.model.search(
49
+ filters=[pyodoo.Filter(field='name',
50
+ compare_type=pyodoo.CompareType.EQUAL,
51
+ value=self.name)],
52
+ limit=1)
53
+ if results:
54
+ self._code_id = results[0]
55
+ else:
56
+ # Python Code object doesn't exist, create it right now
57
+ self._code_id = self.model.create(values={'name': self.name,
58
+ 'code': ''})
59
+
60
+ @staticmethod
61
+ def is_available(endpoint: str,
62
+ database: str,
63
+ username: str,
64
+ password: str,
65
+ language: str) -> bool:
66
+ """
67
+ Check if the execute.python.code model exists
68
+
69
+ :param endpoint: Odoo instance endpoint
70
+ :param database: Odoo database
71
+ :param username: Odoo username
72
+ :param password: User password
73
+ :param language: Language for localizations
74
+
75
+ :return: True if the model execute.python.code exists
76
+ """
77
+ model = Model(model_name='ir.model',
78
+ endpoint=endpoint,
79
+ database=database,
80
+ username=username,
81
+ password=password,
82
+ language=language,
83
+ authenticate=True)
84
+ results = model.search(
85
+ filters=[pyodoo.Filter(field='model',
86
+ compare_type=pyodoo.CompareType.EQUAL,
87
+ value='execute.python.code')],
88
+ limit=1)
89
+ return bool(results)
90
+
91
+ @property
92
+ def name(self) -> str:
93
+ """
94
+ Get the current Python Code name
95
+
96
+ :return: Python Code name
97
+ """
98
+ return self._code_name
99
+
100
+ @property
101
+ def id(self) -> int:
102
+ """
103
+ Get the Python Code object ID
104
+ :return: Python Code object ID
105
+ """
106
+ return self._code_id
107
+
108
+ def get_code(self) -> Optional[str]:
109
+ """
110
+ Get the Python Code text
111
+
112
+ :return: Python text for the Python Code
113
+ """
114
+ results = self.model.get(entity_id=self._code_id,
115
+ fields=('id',
116
+ 'code'))
117
+ return results['code'] if results else None
118
+
119
+ def set_code(self, text: str) -> bool:
120
+ """
121
+ Set the Python Code text
122
+
123
+ :param text: Python text for Python Code
124
+ :return: True if the query was updated
125
+ """
126
+ return self.model.update(entity_id=self._code_id,
127
+ values={'code': text})
128
+
129
+ def execute(self) -> None:
130
+ """
131
+ Execute the Python Code
132
+
133
+ :return: None
134
+ """
135
+ self.model.execute(method_name='execute_code',
136
+ args=[self._code_id],
137
+ kwargs={},
138
+ ignore_none_errors=False)
139
+ return None
140
+
141
+ def get_result(self) -> Optional[str]:
142
+ """
143
+ Get the latest produced result
144
+
145
+ :return: Python Code result
146
+ """
147
+ results = self.model.get(entity_id=self._code_id,
148
+ fields=('result', ))
149
+ return results['result'] if results else None
150
+
151
+ def delete(self) -> bool:
152
+ """
153
+ Delete the Python Code object
154
+
155
+ :return: True if the script was removed
156
+ """
157
+ return self.model.delete(entity_id=self._code_id)
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@ classifiers =
18
18
  Programming Language :: Python :: 3.9
19
19
  Programming Language :: Python :: 3.10
20
20
  Programming Language :: Python :: 3.11
21
+ Programming Language :: Python :: 3.12
21
22
  Topic :: Software Development :: Libraries :: Python Modules
22
23
 
23
24
  [options]
@@ -27,6 +28,7 @@ packages =
27
28
  include_package_data = False
28
29
  install_requires =
29
30
  xlrd==2.0.1
31
+ requests==2.32.3
30
32
 
31
33
  [options.package_data]
32
34
  pyodoo = samples/*
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ class TestCaseCompareTypes(unittest.TestCase):
47
47
  # Check if the results list has exactly one item
48
48
  self.assertEqual(len(results), 1)
49
49
  # Check if the results list contains the Mozzarella Sandwich
50
- self.assertIn(75, results)
50
+ self.assertIn(84, results)
51
51
 
52
52
  def test_02_filter_not_equal(self) -> None:
53
53
  """
@@ -65,7 +65,7 @@ class TestCaseCompareTypes(unittest.TestCase):
65
65
  # Check if the results list has exactly three items
66
66
  self.assertEqual(len(results), 3)
67
67
  # Check if the results list doesn't contain the Mozzarella Sandwich
68
- self.assertNotIn(75, results)
68
+ self.assertNotIn(84, results)
69
69
 
70
70
  def test_03_filter_greater(self) -> None:
71
71
  """
@@ -83,7 +83,7 @@ class TestCaseCompareTypes(unittest.TestCase):
83
83
  # Check if the results list has exactly one item
84
84
  self.assertEqual(len(results), 1)
85
85
  # Check if the results list doesn't contain the Mozzarella Sandwich
86
- self.assertNotIn(75, results)
86
+ self.assertNotIn(84, results)
87
87
 
88
88
  def test_04_filter_greater_equal(self) -> None:
89
89
  """
@@ -101,7 +101,7 @@ class TestCaseCompareTypes(unittest.TestCase):
101
101
  # Check if the results list has exactly two items
102
102
  self.assertEqual(len(results), 2)
103
103
  # Check if the results list contains the Mozzarella Sandwich
104
- self.assertIn(75, results)
104
+ self.assertIn(84, results)
105
105
 
106
106
  def test_05_filter_lower(self) -> None:
107
107
  """
@@ -119,7 +119,7 @@ class TestCaseCompareTypes(unittest.TestCase):
119
119
  # Check if the results list has exactly two items
120
120
  self.assertEqual(len(results), 2)
121
121
  # Check if the results list doesn't contain the Mozzarella Sandwich
122
- self.assertNotIn(75, results)
122
+ self.assertNotIn(84, results)
123
123
 
124
124
  def test_06_filter_lower_equal(self) -> None:
125
125
  """
@@ -137,7 +137,7 @@ class TestCaseCompareTypes(unittest.TestCase):
137
137
  # Check if the results list has exactly three items
138
138
  self.assertEqual(len(results), 3)
139
139
  # Check if the results list contains the Mozzarella Sandwich
140
- self.assertIn(75, results)
140
+ self.assertIn(84, results)
141
141
 
142
142
  def test_07_filter_in(self) -> None:
143
143
  """
@@ -155,9 +155,9 @@ class TestCaseCompareTypes(unittest.TestCase):
155
155
  # Check if the results list has exactly two items
156
156
  self.assertEqual(len(results), 2)
157
157
  # Check if the results list contains the Club Sandwich
158
- self.assertIn(76, results)
158
+ self.assertIn(85, results)
159
159
  # Check if the results list contains the Mozzarella Sandwich
160
- self.assertIn(75, results)
160
+ self.assertIn(84, results)
161
161
 
162
162
  def test_08_filter_not_in(self) -> None:
163
163
  """
@@ -175,9 +175,9 @@ class TestCaseCompareTypes(unittest.TestCase):
175
175
  # Check if the results list has exactly two items
176
176
  self.assertEqual(len(results), 2)
177
177
  # Check if the results list doesn't contain the Club Sandwich
178
- self.assertNotIn(76, results)
178
+ self.assertNotIn(85, results)
179
179
  # Check if the results list doesn't contain the Mozzarella Sandwich
180
- self.assertNotIn(75, results)
180
+ self.assertNotIn(84, results)
181
181
 
182
182
  def test_09_filter_contains(self) -> None:
183
183
  """
@@ -192,7 +192,7 @@ class TestCaseCompareTypes(unittest.TestCase):
192
192
  # Check if the results list has exactly four items
193
193
  self.assertEqual(len(results), 4)
194
194
  # Check if the results list contains the Mozzarella Sandwich
195
- self.assertIn(75, results)
195
+ self.assertIn(84, results)
196
196
 
197
197
  def test_10_filter_contains_not(self) -> None:
198
198
  """
@@ -210,7 +210,7 @@ class TestCaseCompareTypes(unittest.TestCase):
210
210
  # Check if the results list has exactly three items
211
211
  self.assertEqual(len(results), 3)
212
212
  # Check if the results list doesn't contain the Mozzarella Sandwich
213
- self.assertNotIn(75, results)
213
+ self.assertNotIn(84, results)
214
214
 
215
215
  def test_11_filter_not_contains(self) -> None:
216
216
  """
@@ -228,7 +228,7 @@ class TestCaseCompareTypes(unittest.TestCase):
228
228
  # Check if the results list has exactly three items
229
229
  self.assertEqual(len(results), 3)
230
230
  # Check if the results list doesn't contain the Mozzarella Sandwich
231
- self.assertNotIn(75, results)
231
+ self.assertNotIn(84, results)
232
232
 
233
233
  def test_12_filter_like(self) -> None:
234
234
  """
@@ -246,7 +246,7 @@ class TestCaseCompareTypes(unittest.TestCase):
246
246
  # Check if the results list has exactly one item
247
247
  self.assertEqual(len(results), 1)
248
248
  # Check if the results list contains the Mozzarella Sandwich
249
- self.assertIn(75, results)
249
+ self.assertIn(84, results)
250
250
 
251
251
  def test_13_filter_not_like(self) -> None:
252
252
  """
@@ -264,7 +264,7 @@ class TestCaseCompareTypes(unittest.TestCase):
264
264
  # Check if the results list has exactly three items
265
265
  self.assertEqual(len(results), 3)
266
266
  # Check if the results list doesn't contain the Mozzarella Sandwich
267
- self.assertNotIn(75, results)
267
+ self.assertNotIn(84, results)
268
268
 
269
269
  def test_14_filter_ilike(self) -> None:
270
270
  """
@@ -282,7 +282,7 @@ class TestCaseCompareTypes(unittest.TestCase):
282
282
  # Check if the results list has exactly one item
283
283
  self.assertEqual(len(results), 1)
284
284
  # Check if the results list contains the Mozzarella Sandwich
285
- self.assertIn(75, results)
285
+ self.assertIn(84, results)
286
286
 
287
287
  def test_15_filter_not_ilike(self) -> None:
288
288
  """
@@ -300,7 +300,7 @@ class TestCaseCompareTypes(unittest.TestCase):
300
300
  # Check if the results list has exactly three items
301
301
  self.assertEqual(len(results), 3)
302
302
  # Check if the results list doesn't contain the Mozzarella Sandwich
303
- self.assertNotIn(75, results)
303
+ self.assertNotIn(84, results)
304
304
 
305
305
  def test_16_filter_raw_like(self) -> None:
306
306
  """
@@ -318,7 +318,7 @@ class TestCaseCompareTypes(unittest.TestCase):
318
318
  # Check if the results list has exactly one item
319
319
  self.assertEqual(len(results), 1)
320
320
  # Check if the results list contains the Mozzarella Sandwich
321
- self.assertIn(75, results)
321
+ self.assertIn(84, results)
322
322
 
323
323
  def test_17_filter_raw_ilike(self) -> None:
324
324
  """
@@ -336,7 +336,7 @@ class TestCaseCompareTypes(unittest.TestCase):
336
336
  # Check if the results list has exactly one item
337
337
  self.assertEqual(len(results), 1)
338
338
  # Check if the results list contains the Mozzarella Sandwich
339
- self.assertIn(75, results)
339
+ self.assertIn(84, results)
340
340
 
341
341
  def test_18_filter_unset_or_equal(self) -> None:
342
342
  """
@@ -354,7 +354,7 @@ class TestCaseCompareTypes(unittest.TestCase):
354
354
  # Check if the results list has exactly four items
355
355
  self.assertEqual(len(results), 4)
356
356
  # Check if the results list contains the Mozzarella Sandwich
357
- self.assertIn(75, results)
357
+ self.assertIn(84, results)
358
358
 
359
359
  def test_19_filter_child_of(self) -> None:
360
360
  """
@@ -372,7 +372,7 @@ class TestCaseCompareTypes(unittest.TestCase):
372
372
  # Check if the results list has exactly four items
373
373
  self.assertEqual(len(results), 4)
374
374
  # Check if the results list contains the Mozzarella Sandwich
375
- self.assertIn(75, results)
375
+ self.assertIn(84, results)
376
376
 
377
377
  def test_20_filter_parent_of(self) -> None:
378
378
  """
@@ -390,4 +390,4 @@ class TestCaseCompareTypes(unittest.TestCase):
390
390
  # Check if the results list has exactly four items
391
391
  self.assertEqual(len(results), 4)
392
392
  # Check if the results list contains the Mozzarella Sandwich
393
- self.assertIn(75, results)
393
+ self.assertIn(84, results)
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -174,7 +174,7 @@ class TestCaseContacts(unittest.TestCase):
174
174
  self.assertEqual(results[0]['id'], 2)
175
175
  self.assertEqual(results[0]['name'], 'OdooBot')
176
176
  self.assertEqual(results[0]['type'], 'contact')
177
- self.assertGreater(len(results[0]['street']), 0)
177
+ self.assertEqual(results[0]['street'], False)
178
178
 
179
179
  def test_10_find_by_id_both_active(self) -> None:
180
180
  """
@@ -193,7 +193,7 @@ class TestCaseContacts(unittest.TestCase):
193
193
  for item in results:
194
194
  self.assertIn(item['id'], (2, 11))
195
195
  self.assertEqual(item['type'], 'contact')
196
- self.assertGreater(len(item['street']), 0)
196
+ self.assertGreater(len(item['name']), 0)
197
197
 
198
198
  def test_11_find_by_id_multiple(self) -> None:
199
199
  """
@@ -0,0 +1,125 @@
1
+ ##
2
+ # Project: PyOdoo
3
+ # Description: API for Odoo
4
+ # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
+ # Copyright: 2021-2024 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
+ import uuid
23
+
24
+ from pyodoo.v12 import PythonCode
25
+
26
+ import utility
27
+
28
+
29
+ class TestCasePythonCode(unittest.TestCase):
30
+ @classmethod
31
+ def setUpClass(cls):
32
+ """
33
+ Python Code object preparation
34
+ """
35
+ info = utility.get_authentication_from_demo()
36
+ if PythonCode.is_available(endpoint=info['host'],
37
+ database=info['database'],
38
+ username=info['user'],
39
+ password=info['password'],
40
+ language='en_US'):
41
+ # The model sql.excel.pdf is available
42
+ cls.script_name = uuid.uuid4().hex
43
+ cls.script = PythonCode(name=cls.script_name,
44
+ endpoint=info['host'],
45
+ database=info['database'],
46
+ username=info['user'],
47
+ password=info['password'],
48
+ language='en_US')
49
+ else:
50
+ # The model execute.python.code is not available
51
+ cls.script = None
52
+
53
+ def setUp(self):
54
+ """
55
+ Check if the test could be run
56
+ """
57
+ if not self.script:
58
+ self.skipTest('Model execute.python.code is not available')
59
+
60
+ def test_01_get_name(self) -> None:
61
+ """
62
+ Check the Python Code name
63
+ """
64
+ results = self.script.name
65
+ # Check if the name is not None
66
+ self.assertIsNotNone(results)
67
+ # Check if the name is the same
68
+ self.assertEqual(results, self.script_name)
69
+
70
+ def test_02_get_id(self) -> None:
71
+ """
72
+ Check the Python Code ID
73
+ """
74
+ results = self.script.id
75
+ # Check if the ID is not None
76
+ self.assertIsNotNone(results)
77
+ # Check if the ID is > 0
78
+ self.assertGreater(results, 0)
79
+
80
+ def test_03_get_set_code(self) -> None:
81
+ """
82
+ Get the Python Code text
83
+ """
84
+ results = self.script.get_code()
85
+ # Check if the Python Code text is not None
86
+ self.assertIsNotNone(results)
87
+ # Check if the Python Code text length is = 0
88
+ self.assertEqual(len(results), 0)
89
+ # Set new Python Code text
90
+ python_code = ('import sys\n'
91
+ 'result = sys.version')
92
+ results = self.script.set_code(text=python_code)
93
+ # Check if the response is True
94
+ self.assertEqual(results, True)
95
+ # Check if the Python Code text is not None
96
+ results = self.script.get_code()
97
+ self.assertIsNotNone(results)
98
+ # Check if the Python Code text is the expected
99
+ self.assertEqual(results, python_code)
100
+
101
+ def test_04_execute(self) -> None:
102
+ """
103
+ Execute the Python Code
104
+ """
105
+ results = self.script.execute()
106
+ # Check if the Python Code was executed
107
+ self.assertIsNone(results)
108
+
109
+ def test_05_get_result(self) -> None:
110
+ """
111
+ Get the Python Code execution results
112
+ """
113
+ results = self.script.get_result()
114
+ # Check if the result is not None
115
+ self.assertIsNotNone(results)
116
+ # Check if the result is not empty
117
+ self.assertGreater(len(results), 0)
118
+
119
+ def test_06_delete(self) -> None:
120
+ """
121
+ Delete the Python Code
122
+ """
123
+ results = self.script.delete()
124
+ # Check if the deletion was successful
125
+ self.assertTrue(results)
@@ -2,7 +2,7 @@
2
2
  # Project: PyOdoo
3
3
  # Description: API for Odoo
4
4
  # Author: Fabio Castelli (Muflone) <muflone@muflone.com>
5
- # Copyright: 2021-2023 Fabio Castelli
5
+ # Copyright: 2021-2024 Fabio Castelli
6
6
  # License: GPL-3+
7
7
  # This program is free software: you can redistribute it and/or modify
8
8
  # it under the terms of the GNU General Public License as published by
@@ -1 +0,0 @@
1
- xlrd==2.0.1
File without changes
File without changes