Browse Source
Merge pull request #306 from acsone/9.0-rm-shell-sbi
Merge pull request #306 from acsone/9.0-rm-shell-sbi
[DEL][9.0] remove shell which is in official 9.0pull/311/head
Pedro M. Baeza
9 years ago
6 changed files with 0 additions and 170 deletions
-
73shell/README.rst
-
1shell/__init__.py
-
7shell/__openerp__.py
-
0shell/cli/__init__.py
-
89shell/cli/shell.py
-
BINshell/static/description/icon.png
@ -1,73 +0,0 @@ |
|||
CLI shell for Odoo |
|||
================== |
|||
|
|||
Makes available in Odoo 8 the `shell` server command available for Odoo 9. |
|||
|
|||
Installation |
|||
============ |
|||
|
|||
Just install the module. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
Nothing special to be configured. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
To have this feature available this module just need to be in the |
|||
addons path. To use it, in a terminal window run: |
|||
|
|||
$ ./odoo.py shell -d <dbname> |
|||
|
|||
This will initialize a server instance and then jump into a Pyhton |
|||
interactive shell, with full access to the Odoo API. |
|||
|
|||
Example session: |
|||
|
|||
>>> self |
|||
res.users(1,) |
|||
>>> self.name |
|||
u'Administrator' |
|||
>>> self._name |
|||
'res.users' |
|||
>>> self.env |
|||
<openerp.api.Environment object at 0xb3f4f52c> |
|||
>>> self.env['res.partner'].search([('name', 'like', 'Ag')]) |
|||
res.partner(7, 51) |
|||
|
|||
|
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. |
|||
In case of trouble, please check there if your issue has already been reported. |
|||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback |
|||
`here <https://github.com/OCA/server-tools/issues/new?body=module:%20shell%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* OpenERP S.A. |
|||
* Daniel Reis <dgreis@sapo.pt> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: http://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: http://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
OCA, or the Odoo Community Association, is a nonprofit organization whose |
|||
mission is to support the collaborative development of Odoo features and |
|||
promote its widespread use. |
|||
|
|||
To contribute to this module, please visit http://odoo-community.org. |
@ -1 +0,0 @@ |
|||
from .cli import shell |
@ -1,7 +0,0 @@ |
|||
{ |
|||
'name': 'Shell command backport', |
|||
'summary': 'Backport of the v9 shell CLI command.', |
|||
'author': "Daniel Reis,Odoo Community Association (OCA)", |
|||
'version': '8.0.1.0.0', |
|||
'installable': False, |
|||
} |
@ -1,89 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# This program is free software: you can redistribute it and/or modify |
|||
# it under the terms of the GNU Affero General Public License as |
|||
# published by the Free Software Foundation, either version 3 of the |
|||
# License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU Affero General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU Affero General Public License |
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################## |
|||
|
|||
from __future__ import print_function |
|||
import code |
|||
import logging |
|||
import os |
|||
import signal |
|||
import sys |
|||
|
|||
import openerp |
|||
from openerp.api import Environment |
|||
from openerp.cli import Command |
|||
|
|||
|
|||
def raise_keyboard_interrupt(*a): |
|||
raise KeyboardInterrupt() |
|||
|
|||
|
|||
class Console(code.InteractiveConsole): |
|||
def __init__(self, locals=None, filename="<console>"): |
|||
code.InteractiveConsole.__init__(self, locals, filename) |
|||
try: |
|||
import readline |
|||
import rlcompleter |
|||
except ImportError: |
|||
print('readline or rlcompleter not available,' |
|||
' autocomplete disabled.') |
|||
else: |
|||
readline.set_completer(rlcompleter.Completer(locals).complete) |
|||
readline.parse_and_bind("tab: complete") |
|||
|
|||
|
|||
class Shell(Command): |
|||
"""Start odoo in an interactive shell""" |
|||
def init(self, args): |
|||
openerp.tools.config.parse_config(args) |
|||
openerp.cli.server.report_configuration() |
|||
openerp.service.server.start(preload=[], stop=True) |
|||
signal.signal(signal.SIGINT, raise_keyboard_interrupt) |
|||
|
|||
def console(self, local_vars): |
|||
if not os.isatty(sys.stdin.fileno()): |
|||
exec sys.stdin in local_vars |
|||
else: |
|||
if 'env' not in local_vars: |
|||
print('No environment set, use `odoo.py shell -d dbname`' |
|||
' to get one.') |
|||
for i in sorted(local_vars): |
|||
print('%s: %s' % (i, local_vars[i])) |
|||
logging.disable(logging.CRITICAL) |
|||
Console(locals=local_vars).interact() |
|||
|
|||
def shell(self, dbname): |
|||
local_vars = { |
|||
'openerp': openerp |
|||
} |
|||
with Environment.manage(): |
|||
if dbname: |
|||
registry = openerp.modules.registry.RegistryManager.get(dbname) |
|||
with registry.cursor() as cr: |
|||
uid = openerp.SUPERUSER_ID |
|||
ctx = Environment(cr, uid, {})['res.users'].context_get() |
|||
env = Environment(cr, uid, ctx) |
|||
local_vars['env'] = env |
|||
local_vars['self'] = env.user |
|||
self.console(local_vars) |
|||
else: |
|||
self.console(local_vars) |
|||
|
|||
def run(self, args): |
|||
self.init(args) |
|||
self.shell(openerp.tools.config['db_name']) |
|||
return 0 |
Before Width: 128 | Height: 128 | Size: 9.2 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue