Skip to content

Commit

Permalink
Add self to the globals in interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Dec 16, 2018
1 parent e4304a9 commit 6057d1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Changelog
* Accept multiple command line arguments for local mode. Example:
``odooly -- --config path/to/odoo.conf --data-dir ./var``

* Add ``self`` to the ``globals()`` in interactive mode, to mimic
Odoo shell.

* Fix installation/upgrade with an empty list.

* Catch error when database does not exist on login.
Expand Down
2 changes: 2 additions & 0 deletions odooly.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ def connect(self, env_name=None):
pass # client not yet in globals(), or context is None
self._globals['client'] = client
self._globals['env'] = client.env
self._globals['self'] = client.env.user if client.env.uid else None
# Tweak prompt
sys.ps1 = '%s >>> ' % (env_name,)
sys.ps2 = '... '.rjust(len(sys.ps1))
Expand All @@ -1030,6 +1031,7 @@ def context(self, value):
self.env = env = self.env(context=value)
if self._globals and self._globals.get('client') is self:
self._globals['env'] = env
self._globals['self'] = env.user if env.uid else None

@classmethod
def _set_interactive(cls, global_vars={}):
Expand Down

0 comments on commit 6057d1f

Please sign in to comment.