Odooly 3.0.0__tar.gz → 3.0.2__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 (39) hide show
  1. {odooly-3.0.0 → odooly-3.0.2}/CHANGES.rst +25 -4
  2. {odooly-3.0.0 → odooly-3.0.2/Odooly.egg-info}/PKG-INFO +5 -4
  3. {odooly-3.0.0/Odooly.egg-info → odooly-3.0.2}/PKG-INFO +5 -4
  4. {odooly-3.0.0 → odooly-3.0.2}/README.rst +4 -3
  5. {odooly-3.0.0 → odooly-3.0.2}/docs/intro.rst +2 -2
  6. {odooly-3.0.0 → odooly-3.0.2}/odooly/__init__.py +1 -1
  7. {odooly-3.0.0 → odooly-3.0.2}/odooly/_demo.py +3 -4
  8. {odooly-3.0.0 → odooly-3.0.2}/odooly/client.py +1 -1
  9. {odooly-3.0.0 → odooly-3.0.2}/odooly/run.py +42 -28
  10. {odooly-3.0.0 → odooly-3.0.2}/tests/_common.py +11 -2
  11. {odooly-3.0.0 → odooly-3.0.2}/tests/test_client.py +2 -2
  12. {odooly-3.0.0 → odooly-3.0.2}/tests/test_interact.py +6 -2
  13. {odooly-3.0.0 → odooly-3.0.2}/tests/test_util.py +6 -3
  14. {odooly-3.0.0 → odooly-3.0.2}/LICENSE +0 -0
  15. {odooly-3.0.0 → odooly-3.0.2}/Odooly.egg-info/SOURCES.txt +0 -0
  16. {odooly-3.0.0 → odooly-3.0.2}/Odooly.egg-info/dependency_links.txt +0 -0
  17. {odooly-3.0.0 → odooly-3.0.2}/Odooly.egg-info/entry_points.txt +0 -0
  18. {odooly-3.0.0 → odooly-3.0.2}/Odooly.egg-info/requires.txt +0 -0
  19. {odooly-3.0.0 → odooly-3.0.2}/Odooly.egg-info/top_level.txt +0 -0
  20. {odooly-3.0.0 → odooly-3.0.2}/docs/Makefile +0 -0
  21. {odooly-3.0.0 → odooly-3.0.2}/docs/api.rst +0 -0
  22. {odooly-3.0.0 → odooly-3.0.2}/docs/conf.py +0 -0
  23. {odooly-3.0.0 → odooly-3.0.2}/docs/developer.rst +0 -0
  24. {odooly-3.0.0 → odooly-3.0.2}/docs/index.rst +0 -0
  25. {odooly-3.0.0 → odooly-3.0.2}/docs/tutorial.rst +0 -0
  26. {odooly-3.0.0 → odooly-3.0.2}/odooly/__main__.py +0 -0
  27. {odooly-3.0.0 → odooly-3.0.2}/odooly/colorize.py +0 -0
  28. {odooly-3.0.0 → odooly-3.0.2}/odooly/environment.py +0 -0
  29. {odooly-3.0.0 → odooly-3.0.2}/odooly/exceptions.py +0 -0
  30. {odooly-3.0.0 → odooly-3.0.2}/odooly/helpers.py +0 -0
  31. {odooly-3.0.0 → odooly-3.0.2}/odooly/http.py +0 -0
  32. {odooly-3.0.0 → odooly-3.0.2}/odooly/models.py +0 -0
  33. {odooly-3.0.0 → odooly-3.0.2}/odooly/printer.py +0 -0
  34. {odooly-3.0.0 → odooly-3.0.2}/odooly/service.py +0 -0
  35. {odooly-3.0.0 → odooly-3.0.2}/odooly.ini +0 -0
  36. {odooly-3.0.0 → odooly-3.0.2}/pyproject.toml +0 -0
  37. {odooly-3.0.0 → odooly-3.0.2}/setup.cfg +0 -0
  38. {odooly-3.0.0 → odooly-3.0.2}/tests/__init__.py +0 -0
  39. {odooly-3.0.0 → odooly-3.0.2}/tests/test_model.py +0 -0
@@ -2,7 +2,28 @@ Changelog
2
2
  ---------
3
3
 
4
4
 
5
- 3.0.0 (2026-11-11)
5
+ 3.0.2 (2026-11-13)
6
+ ~~~~~~~~~~~~~~~~~~
7
+
8
+ * Remove implicit connection to localhost when argument is missing.
9
+
10
+ * Honor ``--list`` even when standard input is not a terminal.
11
+
12
+
13
+ 3.0.1 (2026-11-13)
14
+ ~~~~~~~~~~~~~~~~~~
15
+
16
+ * Fix usage like ``odooly https://demo.odoo.com``.
17
+
18
+ * Fix error when more than one database exists, in non-interactive mode.
19
+
20
+ * Accept ``--env`` and ``--db`` simultaneously.
21
+
22
+ * New environment variable ``ODOOLY_USAGE`` to change or remove message
23
+ printed when interactive shell is started.
24
+
25
+
26
+ 3.0.0 (2026-11-12)
6
27
  ~~~~~~~~~~~~~~~~~~
7
28
 
8
29
  **BREAKING CHANGE**: Project is no longer a single file. It is reorganized with a traditional
@@ -14,9 +35,9 @@ package structure. As a consequence, some import paths have to be adapted in yo
14
35
  variable ``ODOOLY_HISTFILE``.
15
36
  * Support running wheel file without installing:
16
37
  ``python odooly-3.0.0-py3-none-any.whl/odooly --version``
17
- * Switch the project to a package structure
18
- * Build: migrate to pyproject.toml
19
- * Build: change Web theme for documentation
38
+ * Switch the project to a package structure.
39
+ * Build: migrate to pyproject.toml.
40
+ * Build: change Web theme for documentation.
20
41
 
21
42
 
22
43
  2.6.9 (2026-11-06)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Odooly
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Versatile tool for Odoo
5
5
  Author-email: Florent Xicluna <florent.xicluna@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -38,11 +38,11 @@ Odooly, a versatile tool for Odoo
38
38
 
39
39
  Install with `uv <https://docs.astral.sh/uv/#installation>`_::
40
40
 
41
- uv tool install -U odooly
41
+ uv tool install -U odooly[requests]
42
42
 
43
43
  Or with Pip::
44
44
 
45
- pip install -U odooly
45
+ pip install -U odooly[requests]
46
46
 
47
47
  As an alternative, ``uv`` can invoke Odooly without installing::
48
48
 
@@ -74,8 +74,9 @@ Key features:
74
74
  - simplified syntax for search ``domain``
75
75
  - entire API accessible on the ``Client.env`` environment
76
76
  - can be imported and used as a library: ``from odooly import Client``
77
+ - no external dependency: ``requests`` is optional
78
+ - can use without installing: ``python path/to/odooly.whl/odooly --help``
77
79
  - supports Python 3.8 and more recent
78
- - no external dependency, can use without installing
79
80
 
80
81
 
81
82
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Odooly
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: Versatile tool for Odoo
5
5
  Author-email: Florent Xicluna <florent.xicluna@gmail.com>
6
6
  License-Expression: BSD-3-Clause
@@ -38,11 +38,11 @@ Odooly, a versatile tool for Odoo
38
38
 
39
39
  Install with `uv <https://docs.astral.sh/uv/#installation>`_::
40
40
 
41
- uv tool install -U odooly
41
+ uv tool install -U odooly[requests]
42
42
 
43
43
  Or with Pip::
44
44
 
45
- pip install -U odooly
45
+ pip install -U odooly[requests]
46
46
 
47
47
  As an alternative, ``uv`` can invoke Odooly without installing::
48
48
 
@@ -74,8 +74,9 @@ Key features:
74
74
  - simplified syntax for search ``domain``
75
75
  - entire API accessible on the ``Client.env`` environment
76
76
  - can be imported and used as a library: ``from odooly import Client``
77
+ - no external dependency: ``requests`` is optional
78
+ - can use without installing: ``python path/to/odooly.whl/odooly --help``
77
79
  - supports Python 3.8 and more recent
78
- - no external dependency, can use without installing
79
80
 
80
81
 
81
82
 
@@ -4,11 +4,11 @@ Odooly, a versatile tool for Odoo
4
4
 
5
5
  Install with `uv <https://docs.astral.sh/uv/#installation>`_::
6
6
 
7
- uv tool install -U odooly
7
+ uv tool install -U odooly[requests]
8
8
 
9
9
  Or with Pip::
10
10
 
11
- pip install -U odooly
11
+ pip install -U odooly[requests]
12
12
 
13
13
  As an alternative, ``uv`` can invoke Odooly without installing::
14
14
 
@@ -40,8 +40,9 @@ Key features:
40
40
  - simplified syntax for search ``domain``
41
41
  - entire API accessible on the ``Client.env`` environment
42
42
  - can be imported and used as a library: ``from odooly import Client``
43
+ - no external dependency: ``requests`` is optional
44
+ - can use without installing: ``python path/to/odooly.whl/odooly --help``
43
45
  - supports Python 3.8 and more recent
44
- - no external dependency, can use without installing
45
46
 
46
47
 
47
48
 
@@ -12,11 +12,11 @@ Installation
12
12
  Download and install the `latest release
13
13
  <https://pypi.org/project/Odooly>`__ from PyPI::
14
14
 
15
- uv tool install -U odooly
15
+ uv tool install -U odooly[requests]
16
16
 
17
17
  Or::
18
18
 
19
- pip install -U odooly
19
+ pip install -U odooly[requests]
20
20
 
21
21
  As an alternative, ``uv`` can invoke Odooly without installing::
22
22
 
@@ -1,5 +1,5 @@
1
1
  """Odoo client library and command line tool"""
2
- __version__ = '3.0.0'
2
+ __version__ = '3.0.2'
3
3
 
4
4
  from .client import Client
5
5
  from .environment import Env
@@ -42,10 +42,9 @@ def _retrieve_servers(url=RUNBOT_URL, regex=RUNBOT_REGEX, user=None, headers=RUN
42
42
  test_servers = collections.defaultdict(set)
43
43
  overview = HTTPSession().request(url, method='GET', headers=headers)
44
44
  builds = re.findall(regex, overview, re.DOTALL)
45
- if not builds:
46
- if os.getenv("ODOOLY_DEBUG"):
47
- fdump = Path.cwd() / "runbot_odoo_com.html"
48
- fdump.write_text(overview)
45
+ if not builds and os.getenv("ODOOLY_DEBUG"):
46
+ fdump = Path.cwd() / "runbot_odoo_com.html"
47
+ fdump.write_text(overview)
49
48
  raise SystemExit(f"Could not parse content of {RUNBOT_HOST}:\n check here \"{fdump}\"")
50
49
  for edition, domain, build, ver in builds:
51
50
  suffix = "+e" if edition == "Enterprise" else ""
@@ -230,7 +230,7 @@ class Client:
230
230
  if not database:
231
231
  # Database selector page
232
232
  database = self._select_database(dbs)
233
- elif dbs and database not in dbs:
233
+ if dbs and database not in dbs:
234
234
  raise Error(f"Database {database!r} does not exist: {dbs}")
235
235
  if database and env.db_name != database:
236
236
  if self._session_uid:
@@ -17,7 +17,6 @@ from .printer import Printer, convert_to_width, pp, set_output_width
17
17
 
18
18
  CONF_FILE = 'odooly.ini'
19
19
  HIST_FILE = '~/.odooly_history'
20
- DEFAULT_URL = 'http://localhost:8069/'
21
20
 
22
21
  USAGE = """\
23
22
  Usage (some commands):
@@ -100,7 +99,7 @@ class InteractiveClient(Client):
100
99
  return saved_config[environment]
101
100
 
102
101
  @classmethod
103
- def from_config(cls, environment, user=None, verbose=False):
102
+ def from_config(cls, environment, *, user=None, database=None, verbose=False):
104
103
  """Create a connection to a defined environment.
105
104
 
106
105
  See :meth:`InteractiveClient.get_config`
@@ -112,9 +111,9 @@ class InteractiveClient(Client):
112
111
  try:
113
112
  client = Env._cache[Env, db, server].client
114
113
  client.verbose = verbose
115
- client.login(user or conf_user, password=password, api_key=api_key)
114
+ client.login(user or conf_user, password=password, database=database, api_key=api_key)
116
115
  except KeyError:
117
- client = cls(server, db, user or conf_user,
116
+ client = cls(server, database or db, user or conf_user,
118
117
  password=password, api_key=api_key, verbose=verbose)
119
118
  return client.save(environment, skip=skip_save)
120
119
 
@@ -132,7 +131,7 @@ class InteractiveClient(Client):
132
131
  Return tuple ``(server, db or None, user, password or None, api_key or None)``.
133
132
  Without argument, it returns the list of configured environments.
134
133
  """
135
- if not cls._config_file.exists():
134
+ if not cls._config_file or not cls._config_file.is_file():
136
135
  if section is None:
137
136
  return []
138
137
  raise FileNotFoundError(cls._config_file)
@@ -187,7 +186,7 @@ class InteractiveClient(Client):
187
186
  """Connect to another environment and replace the globals()."""
188
187
  assert self._is_interactive(), 'Not available'
189
188
  if env_name:
190
- self.from_config(env_name, user=user, verbose=self.verbose)
189
+ self.from_config(env_name, user=user, database=database, verbose=self.verbose)
191
190
  elif server:
192
191
  if not user and self.env.uid:
193
192
  user = self.env.user.login
@@ -244,7 +243,7 @@ def _interact(global_vars, use_pprint=True, usage=USAGE):
244
243
  readline.set_history_length(int(os.getenv('HISTSIZE', 500)))
245
244
  # better append instead of replace?
246
245
  atexit.register(readline.write_history_file, hist_file)
247
- except Exception as exc:
246
+ except Exception:
248
247
  pass # No history in case of error
249
248
 
250
249
  if use_pprint:
@@ -279,11 +278,11 @@ def get_parser():
279
278
  '--env',
280
279
  help='read connection settings from the given section')
281
280
  parser.add_argument(
282
- '-c', '--config', default=CONF_FILE,
281
+ '-c', '--config', default=None, type=Path,
283
282
  help=f'specify alternate config file (default: {CONF_FILE})')
284
283
  parser.add_argument(
285
284
  '--server', default=None,
286
- help=f'full URL of the server (default: {DEFAULT_URL})')
285
+ help=f'full URL of the server')
287
286
  parser.add_argument('-d', '--db', default=None, help='database')
288
287
  parser.add_argument('-u', '--user', default=None, help='username')
289
288
  parser.add_argument(
@@ -308,16 +307,27 @@ def get_parser():
308
307
 
309
308
  def connect_client(args):
310
309
  if (env_name := args.demo or args.env):
311
- client = InteractiveClient.from_config(env_name, user=args.user, verbose=args.verbose)
310
+ kwargs = {
311
+ "user": args.user,
312
+ "database": args.db,
313
+ "verbose": args.verbose,
314
+ }
315
+ client = InteractiveClient.from_config(env_name, **kwargs)
312
316
  else:
313
- if not args.server:
314
- args.server = ['-c', args.config] if args.config else DEFAULT_URL
315
- if args.args:
316
- args.server = args.server + args.args if args.config else ' '.join(args.args)
317
- if not args.user:
318
- args.user = ADMIN_USER
319
- client = InteractiveClient(args.server, args.db, args.user, password=args.password,
320
- api_key=args.api_key, verbose=args.verbose)
317
+ if args.server:
318
+ server = args.server
319
+ elif not args.config:
320
+ server = ' '.join(args.args)
321
+ elif args.args:
322
+ server = ['-c', args.config] + args.args
323
+ else:
324
+ server = ['-c', args.config]
325
+ kwargs = {
326
+ "password": args.password,
327
+ "api_key": args.api_key,
328
+ "verbose": args.verbose,
329
+ }
330
+ client = InteractiveClient(server, args.db, args.user or ADMIN_USER, **kwargs)
321
331
  return client
322
332
 
323
333
 
@@ -341,26 +351,29 @@ def main(interact=_interact):
341
351
 
342
352
  If it is not interactive, execute script received on standard input.
343
353
  """
344
- args = get_parser().parse_args()
345
- is_interactive_shell = sys.stdin.isatty()
354
+ aparser = get_parser()
355
+ args = aparser.parse_args()
346
356
 
347
357
  client_class = InteractiveClient
348
- client_class._config_file = Path.cwd() / args.config
358
+ client_class._config_file = Path.cwd() / (args.config or CONF_FILE)
349
359
 
350
360
  if args.demo:
351
361
  from ._demo import _retrieve_servers
352
362
 
353
363
  client_class._saved_config_demo = _retrieve_servers(user=args.user or "demo")
354
-
355
- if not is_interactive_shell: # Read and execute commands from standard input
356
- client = connect_client(args)
357
- exec(compile(sys.stdin.read(), '<stdin>', 'exec'), {'client': client, 'env': client.env})
358
- return
359
364
  if args.list_env:
360
365
  print('Available settings: ' + ' '.join(client_class.read_config()))
361
366
  if args.demo:
362
367
  print(' ' + ' '.join(client_class._saved_config_demo))
363
368
  return
369
+ if not (args.args or args.server or args.config or args.env or args.demo):
370
+ aparser.error("missing argument")
371
+
372
+ is_interactive_shell = sys.stdin.isatty()
373
+ if not is_interactive_shell: # Read and execute commands from standard input
374
+ client = connect_client(args)
375
+ exec(compile(sys.stdin.read(), '<stdin>', 'exec'), {'client': client, 'env': client.env})
376
+ return
364
377
 
365
378
  # Interactive mode
366
379
  client_class._globals = {
@@ -371,7 +384,8 @@ def main(interact=_interact):
371
384
  }
372
385
  if not interact:
373
386
  return connect_client(args)._globals
387
+ usage = os.getenv('ODOOLY_USAGE', USAGE)
374
388
  install_colors(client_class._globals)
375
389
  install_signal_handler()
376
- print(color_repr(USAGE))
377
- return interact(connect_client(args)._globals)
390
+ print(color_repr(usage))
391
+ return interact(connect_client(args)._globals, usage=usage)
@@ -73,9 +73,18 @@ class OdooTestCase(TestCase):
73
73
  'Content-Type': 'application/json',
74
74
  'X-Odoo-Database': self.database,
75
75
  }
76
- expected_calls[idx] = call(f"{server}{expected[0]}", json=expected[1], headers=headers)
76
+ expected_calls[idx] = call(
77
+ f"{server}{expected[0]}",
78
+ json=expected[1],
79
+ headers=headers,
80
+ )
77
81
  elif expected[0].startswith('/web/'):
78
- jsonrpc_params = {'jsonrpc': '2.0', 'method': 'call', 'params': expected[1], 'id': ANY}
82
+ jsonrpc_params = {
83
+ 'jsonrpc': '2.0',
84
+ 'method': 'call',
85
+ 'params': expected[1],
86
+ 'id': ANY,
87
+ }
79
88
  expected_calls[idx] = call(f"{server}{expected[0]}", json=jsonrpc_params)
80
89
  self.assertMockCalls(self.http_request, expected_calls)
81
90
 
@@ -156,8 +156,8 @@ class TestCreateClient(JsonRpcTestCase):
156
156
  self.service.common.login.return_value = 1
157
157
 
158
158
  s_context = '{"lang": "en_US", "tz": "Europe/Zurich"}'
159
- key_1 = b"\0\0\0\1" + bytes.fromhex(f'{hash("{}")%2**32:08x}')
160
- key_2 = b"\0\0\0\1" + bytes.fromhex(f'{hash(s_context)%2**32:08x}')
159
+ key_1 = b"\0\0\0\1" + bytes.fromhex(f'{hash("{}") % 2**32:08x}')
160
+ key_2 = b"\0\0\0\1" + bytes.fromhex(f'{hash(s_context) % 2**32:08x}')
161
161
  client = odooly.Client(self.server, 'newdb', 'usr', 'pss')
162
162
  expected_calls = self.startup_calls + (
163
163
  call.common.login('newdb', 'usr', 'pss'),
@@ -23,6 +23,8 @@ class _TestInteract(OdooTestCase):
23
23
  self.interact = mock.patch('odooly.run._interact', wraps=odooly.run._interact).start()
24
24
  self.infunc = mock.patch('code.InteractiveConsole.raw_input').start()
25
25
  mock.patch('odooly.run.main.__defaults__', (self.interact,)).start()
26
+ # OSError: [Errno 25] Inappropriate ioctl for device
27
+ mock.patch('odooly.run.handle_resize').start()
26
28
 
27
29
  def _resp_version_info(self):
28
30
  [major, minor] = self.server_version.split('.')
@@ -231,10 +233,12 @@ class TestInteract19(_TestInteract):
231
233
  self.assertEqual(sys.ps1, 'demo >>> ')
232
234
  self.assertEqual(sys.ps2, ' ... ')
233
235
  expected_calls = self.startup_calls + (
234
- ('/web/session/authenticate', {'db': 'database', 'login': 'gaspard', 'password': 'password'}),
236
+ ('/web/session/authenticate',
237
+ {'db': 'database', 'login': 'gaspard', 'password': 'password'}),
235
238
  ('/json/2/res.users/context_get', {}),
236
239
  call(f'{self.server}doc/res.device.json', method='GET'),
237
- ('/web/session/authenticate', {'db': 'database', 'login': 'gaspard', 'password': 'password'}),
240
+ ('/web/session/authenticate',
241
+ {'db': 'database', 'login': 'gaspard', 'password': 'password'}),
238
242
  )
239
243
  self.assertRequests(*expected_calls)
240
244
  self.assertEqual(getpass.call_count, 2)
@@ -152,8 +152,10 @@ class TestUtils(TestCase):
152
152
  "'duration': datetime.timedelta(days=3, seconds=42, microseconds=200000)}]}"
153
153
  )
154
154
  expected = {
155
- 'create_date': dt_.datetime(2001, 12, 31, 23, 59, 0, tzinfo=dt_.timezone(dt_.timedelta(seconds=19800))),
156
- 'write_date': dt_.datetime(2024, 2, 29, 1, 1, 1, tzinfo=dt_.timezone.utc),
155
+ 'create_date': dt_.datetime(2001, 12, 31, 23, 59, 0,
156
+ tzinfo=dt_.timezone(dt_.timedelta(seconds=19800))),
157
+ 'write_date': dt_.datetime(2024, 2, 29, 1, 1, 1,
158
+ tzinfo=dt_.timezone.utc),
157
159
  'duration': dt_.timedelta(days=3, seconds=42, microseconds=200000)
158
160
  }
159
161
  self.assertEqual(literal_eval(result), {'result': [expected]})
@@ -163,7 +165,8 @@ class TestUtils(TestCase):
163
165
  readfmt = partial(dummy._parse_format, browse=False)
164
166
 
165
167
  # Helper for 'read' methods
166
- (fields, fmt) = readfmt('a {color} elephant enters {location[1]}.\n\n{firstname!r} has left')
168
+ (fields, fmt) = readfmt('a {color} elephant enters {location[1]}.\n\n'
169
+ '{firstname!r} has left')
167
170
  self.assertEqual(fields, ['color', 'location', 'firstname'])
168
171
 
169
172
  def test_printer(self):
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
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
File without changes
File without changes
File without changes