Skip to content

Commit

Permalink
Merge pull request #2 from katyukha/python_3_support
Browse files Browse the repository at this point in the history
Python 3 support
  • Loading branch information
katyukha committed Sep 7, 2015
2 parents 40e9369 + bee1df5 commit 1d3f88d
Show file tree
Hide file tree
Showing 49 changed files with 1,819 additions and 698 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
@@ -0,0 +1,4 @@
[run]
omit =
openerp_proxy/tests/*.*
openerp_proxy/main.py
8 changes: 7 additions & 1 deletion .travis.yml
@@ -1,17 +1,23 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
# - "3.5"

env:
- ODOO_VERSION="8.0" ODOO_PACKAGE="odoo" ODOO_TEST_PROTOCOL='xml-rpc'
- ODOO_VERSION="8.0" ODOO_PACKAGE="odoo" ODOO_TEST_PROTOCOL='json-rpc'
- ODOO_VERSION="7.0" ODOO_PACKAGE="openerp" ODOO_TEST_PROTOCOL='xml-rpc'
- ODOO_VERSION="8.0" ODOO_PACKAGE="odoo" ODOO_TEST_PROTOCOL='xml-rpc' TEST_WITH_EXTENSIONS='openerp_proxy.ext.all'
- ODOO_VERSION="8.0" ODOO_PACKAGE="odoo" ODOO_TEST_PROTOCOL='json-rpc' TEST_WITH_EXTENSIONS='openerp_proxy.ext.all'
- ODOO_VERSION="7.0" ODOO_PACKAGE="openerp" ODOO_TEST_PROTOCOL='xml-rpc' TEST_WITH_EXTENSIONS='openerp_proxy.ext.all'

install:
- "wget http://nightly.odoo.com/${ODOO_VERSION}/nightly/deb/${ODOO_PACKAGE}_${ODOO_VERSION}.latest_all.deb"
- "sudo dpkg -i ${ODOO_PACKAGE}_${ODOO_VERSION}.latest_all.deb || true"
- "sudo apt-get update && sudo apt-get install -f -y"
- "pip install coveralls"
- "pip install coveralls mock simple-crypt ipython[notebook]"
- "python setup.py develop"

before_script:
Expand Down
17 changes: 14 additions & 3 deletions CHANGELOG.rst
@@ -1,17 +1,28 @@
master:
- *Backward incompatible*: Changed session file format.
*Start up imports* and *extra_paths* moved to *options* section of file.
- *Backward incompatible*: ``IPYSession`` moved to ``openerp_proxy.ext.repr`` extensions.
Now when using IPython notebook, this extension have to be imported first,
to enable HTML representation of session object
- *Backward incompatible*: Changed signature of ``Session.connect()`` method.
- *Backward incompatible*: Renamed ``ERP_Proxy`` to ``Client`` and inherited objects renamed in such way
(for example sugar extension module)
- *Backward incompatible*: removed ``ERP_Proxy` and ``ERP_Session`` compatability aliases

- Changed ``store_passwords`` option meaning. now if set it will store passwords bese64 encoded,
instead of using simple-crypt module. This change makes it faster to decode password,
because last-versions of simple-crypt become too slow. and usualy no encryption needed here.
- Experimental *Python 3.3+* support
- Added ``HField.with_args`` method.
- Added basic implementation of graph plugin.
- Improved ``openerp_proxy.ext.log_execute_console`` extension. Added timing.
- Added ``Client.clean_caches()`` method, which is used to clean cache of registered models
- RecordList prefetching logic moved to cache module and highly refactored
(Added support of prefetching of related fields)
- Added ``Client.login(dbname, user, password)`` method.
- Changed signature of ``Session.connect()`` method.
- Added ``HTMLTable.update`` method.
- Added ``RecordList.copy()`` and ``RecordList.existing()`` methods.
- Added ``HTMLTable.to_csv()`` method.
- Renamed ``ERP_Proxy`` to ``Client`` and inherited objects renamed in such way
(for example sugar extension module)
- Added ``Client.server_version`` property
- Client parametrs (dbname, user, pwd) now are not required.
This is useful when working with ``db`` service (``client.services.db``)
Expand Down
100 changes: 44 additions & 56 deletions README.rst
Expand Up @@ -17,7 +17,7 @@ Overview
This project is just **RPC client** for Odoo.
It aims to ease access to openerp data via shell and used
mostly for data debuging purposes. This project provides interface similar to
OpenERP internal code to perform operations on **OpenERP** / **Odoo** objects hiding
Odoo internal code to perform operations on **OpenERP** / **Odoo** objects hiding
**XML-RPC** or **JSON-RPC** behind.


Expand All @@ -28,67 +28,54 @@ OpenERP internal code to perform operations on **OpenERP** / **Odoo** objects hi
Features
~~~~~~~~

- supports call to all public methods on any OpenERP/Odoo object including:
- *Python 3.3+* support
- You can call any public method on any OpenERP / Odoo object including:
*read*, *search*, *write*, *unlink* and others
- Have *a lot of speed optimizations* (especialy for situation, where required processing of
large datasets)
- Have *a lot of speed optimizations* (caching, read only fields accessed,
read data for all records in current set, by one RPC call, etc)
- Desinged to take as more benefits of **IPython autocomplete** as posible
- Works nice in **IPython Notebook** providing **HTML
representation** for a most of objects.
- Ability to display set of records as **HTML Table**
including conditional **row highlighting**.
(Useful in IPython Notebook for *data-analysis*)
- Ability to represent HTML table also as *CSV file*
- Provides session/history functionality, so if You used it to connect to
some database before, new connection will be simpler (just enter password).
Version 0.5 and higher have ability to store passwords. just use
``session.option('store_passwords', True); session.save()``
- Ability to export HTML table recordlist representation to *CSV file*
- Ability to save connections to different databases in session.
(By default password is not saved, and will be asked, but if You need to save it, just do this:
``session.option('store_passwords', True); session.save()``)
- Provides *browse\_record* like interface, allowing to browse related
models too. Supports *browse* method. Adds method *search\_records* to simplify
models too. Supports *browse* method. Also adds method *search\_records* to simplify
search-and-read operations.
- *Extension support*. You can easily modify most of components of this app/lib
creating Your own extensions. It is realy simple. See for examples in
creating Your own extensions and plugins. It is realy simple. See for examples in
openerp_proxy/ext/ directory.
- *Plugin Support*. Plugins here meant utils, which could store some aditional
logic, to simplify routine operations.
Accessible from ``db.plugins.<plugin_name>`` attribute.
- Support of **JSON-RPC** for *version 8* of OpenERP/Odoo (***experimental***)
- *Plugin Support*. Plugins are same as extensions, but aimed to implement additional logic.
For example look at *openerp_proxy/plugins* and *openerp_proxy/plugin.py*
- Support of **JSON-RPC** for *version 8+* of Odoo
- Support of using **named parametrs** in RPC method calls (server version 6.1 and higher).
- *Sugar extension* which simplifys code a lot.

- Missed feature? ask in `Project Issues <https://github.com/katyukha/openerp-proxy/issues>`_


Constraints
~~~~~~~~~~~
Supported Python versions
~~~~~~~~~~~~~~~~~~~~~~~~~

For High level functionality Odoo server must be of version 6.1 or higher
Support Python 2.7, 3.3, 3.4


Examples
~~~~~~~~
Supported Odoo server versions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- `Examples & HTML tests <http://nbviewer.ipython.org/github/katyukha/openerp-proxy/blob/master/examples/Examples%20&%20HTML%20tests.ipynb>`_
Tested with Odoo 7.0 and 8.0

Also shoud work with Odoo 6.1 and 9.0

What You can do with this
~~~~~~~~~~~~~~~~~~~~~~~~~
Also it should work with Odoo version 6.0, except the things related to passing named parametrs
to server methods, such as using context in ``openerp_proxy.orm`` package

- Quickly read and analyze some data that is not visible in interface
without access to DB
- Use this project as library for code that need to access OpenERP data
- Use in scripts that migrates OpenERP data (after, for example, adding
new functionality or changing old). (Migration using only SQL is bad
idea because of functional fields with *store=True* which must be
recalculated).

Near future plans
~~~~~~~~~~~~~~~~~
Examples
~~~~~~~~

- Django-like search API implemented as extension
- Something like ``F`` or ``Q`` expressions from Django
- to make working constructions like:
``object.filter((F('price') > 100.0) & (F('price') != F('Price2')))``
- `Examples & HTML tests <http://nbviewer.ipython.org/github/katyukha/openerp-proxy/blob/master/examples/Examples%20&%20HTML%20tests.ipynb>`_


Install
Expand All @@ -107,7 +94,7 @@ If You want to install development version of *OpenERP Proxy* you can do it via:


Also if You plan to use this project as shell client, it is **recommended to install IPython**
and If You would like to have ability to play with Odoo / OpenERP data in IPython notebook,
and If You would like to have ability to play with Odoo data in IPython notebook,
it is recommended to also install IPython's Notebook support. To install IPython and IPython Notebook
just type::

Expand All @@ -127,14 +114,14 @@ And You will get the openerp_proxy shell. If *IPython* is installed then IPython
will be used, else usual python shell will be used. There is in context exists
*session* variable that represents current session to work with

Next You have to get connection to some OpenERP/Odoo database.
Next You have to get connection to some Odoo database.

::

>>> db = session.connect()

This will ask You for host, port, database, etc to connect to. Now You
have connection to OpenERP database which allows You to use database
have connection to Odoo database which allows You to use database
objects.


Expand All @@ -152,11 +139,11 @@ So here is a way to create connection

::

import openerp_proxy.core as oe_core
db = oe_core.Client(dbname='my_db',
host='my_host.int',
user='my_db_user',
pwd='my_password here')
from openerp_proxy.core import Client
db = Client(host='my_host.int',
dbname='my_db',
user='my_db_user',
pwd='my_password here')

And next all there same, no more differences betwen shell and lib usage.

Expand All @@ -168,13 +155,13 @@ To better suit for HTML capable notebook You would like to use IPython's version
object and *openerp_proxy.ext.repr* extension.
So in first cell of notebook import session and extensions/plugins You want::

from openerp_proxy.session import IPYSession as Session # Use IPython-itegrated session class
import openerp_proxy.ext.repr # Enable representation extension. This provides HTML representation of objects
from openerp_proxy.ext.repr import HField # Used in .as_html_table method of RecordList

# also You may import all standard extensions in one line:
from openerp_proxy.ext.all import *

# note that extensions were imported before session,
# because some of them modify Session class
from openerp_proxy.session import Session

session = Session()

Now most things same as for shell usage, but...
Expand All @@ -186,9 +173,10 @@ To solve this, it is recommended to uses *store_passwords* option::
session.option('store_passwords', True)
session.save()

In this way, only when You connect first time, You need to explicitly pass password to *connect* of *get_db* methods.
Next use it likt shell (or like lib), but *do not forget to save session, after new connection*

(*do not forget to save session, after new connection*)
*Note*: in old version of IPython getpass was not work correctly,
so maybe You will need to pass password directly to *session.connect* method.


General usage
Expand All @@ -207,9 +195,9 @@ database:

So we have 5 orders in done state. So let's read them.

Default way to read data from OpenERP is to search for required records
Default way to read data from Odoo is to search for required records
with *search* method which return's list of IDs of records, then read
data using *read* method. Both methods mostly same as OpenERP internal
data using *read* method. Both methods mostly same as Odoo internal
ones:

::
Expand Down Expand Up @@ -348,7 +336,7 @@ So let's start

``vim attendance.py``

3. write folowing code there (note that this example works and tested for Odoo version 6.0)
3. write folowing code there (note that this example works and tested for Odoo version 6.0 only)

::

Expand Down
2 changes: 1 addition & 1 deletion bin/openerp_proxy
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-

from openerp_proxy import main
from openerp_proxy.main import main

if __name__ == '__main__':
main()
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Expand Up @@ -51,7 +51,7 @@

# General information about the project.
project = u'openerp_proxy'
copyright = u'2014, Dmytro Katyukha'
copyright = u'2015, Dmytro Katyukha'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -105,7 +105,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down

0 comments on commit 1d3f88d

Please sign in to comment.