Package: odoo-rpc-client
ContentsCanonical sourceOverviewFeaturesQuick exampleSupported Odoo server versionsInstallYodoo Cockpit - Manage your odoo infrastructure via odooLevel up your service qualityUsageConnect to server / databaseGeneral usageAdditional featuresCanonical sourceThe canonical source ofodoo-rpc-clientis hosted onGitLab.OverviewThis is core part ofOpenERP ProxyThis project is justRPC clientfor Odoo.
This project provides interface similar to
Odoo internal code to perform operations onOdooobjects hidingXML-RPCorJSON-RPCbehind.FeaturesPython 3.5+supportYou can call any public method on any OpenERP / Odoo object including:read,search,write,unlinkand othersHavea lot of speed optimizations(caching, read only requested fields,
read data for all records in current set (cache), by one RPC call, etc)Desinged to take as more benefits ofIPython autocompleteas posibleProvidesbrowse_recordlike interface, allowing to browse related
models too. Supportsbrowsemethod.
Also adds methodsearch_recordsto simplify
search-and-read operations.Extension support. You can easily modify most of components of this lib
creating Your own extensions and plugins. It is realy simple. See for examples inopenerp_proxy/ext/directory.Plugin Support. Plugins are same as extensions, but aimed to implement additional logic.
For example look atodoo_rpc_client/pluginsandodoo_rpc_client/plugin.pySupport ofJSON-RPCforversion 8+of OdooSupport of usingnamed parametrsin RPC method calls (server version 6.1 and higher).Experimentalintegration withAnyFieldMissed feature? fill and issue onGitHuborGitLabQuick examplefromodoo_rpc_clientimportClient# assume that odoo server is listening localhost on standard 8069 port and# have database 'my_db'.client=Client('localhost','my_db','user','password')# get current userclient.userprint(client.user.name)# simple rpc callsclient.execute('res.partner','read',[client.user.partner_id.id])# Model browsingSaleOrder=client['sale.order']s_orders=SaleOrder.search_records([])fororderins_orders:print(order.name)forlineinorder.order_line:print("\t%s"%line.name)print("-"*5)print()Supported Odoo server versionsTested with:
- Odoo versions:10.0,11.0,12.0,13.0,14.0- Python versions:2.7,3.5,3.6,3.7,3.8,3.9InstallThis project is present onPyPIso it could be installed via PIP:pip install odoo_rpc_clientYodoo Cockpit - Manage your odoo infrastructure via odooTake a look atYodoo Cockpitproject, and discover the easiest way to manage your odoo installation.
Just short notes aboutYodoo Cockpit:start new production-ready odoo instance in 1-2 minutes.add custom addons to your odoo instances in 5-10 minutes.out-of-the-box email configuration: just press button and add some records to your DNS, and get a working emailmake your odoo instance available to external world (internet) in 30 seconds (just add single record in your DNS)If you have any questions, then contact us atinfo@crnd.pro, so we could schedule online-demonstration.Level up your service qualityLevel up your service with ourHelpdesk/Service Desk/ITSMsolution.Just test it atyodoo.systems: choose template you like, and start working.Test all available features ofBureaucrat ITSMwiththis template.UsageConnect to server / databaseThe one diference betwen using as lib and using as shell is the way
connection to database is created. When using as shell the primary object
is session, which provides some interactivity. But when using as library
in most cases there are no need for that interactivity, so connection
should be created manualy, providing connection data from some other sources
like config file or something else.So here is a way to create connectionfromodoo_rpc_clientimportClientdb=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.General usageFor example lets try to find how many sale orders in ‘done’ state we have in
our database. (Look above sections to get help on how to connect to Odoo database)>>>sale_order_obj=db['sale.order']# or You may use 'db.get_obj('sale.order')' if You like>>>>>># Now lets search for sale orders:>>>sale_order_obj.search([('state','=','done')],count=True)5So we have 5 orders in done state. So let’s read them.Default way to read data from Odoo is to search for required records
withsearchmethod which return’s list of IDs of records, then read
data usingreadmethod. Both methods mostly same as Odoo internal
ones:>>>sale_order_ids=sale_order_obj.search([('state','=','done')])>>>sale_order_datas=sale_order_obj.read(sale_order_ids,['name'])# Last argument is optional.# it describes list of fields to read# if it is not provided then all fields# will be read>>>sale_order_datas[0]{'id':3,'name':'SO0004'}As we see reading data in such way allows us to get list of dictionaries
where each contain fields have been readAnother way to read data is to usesearch_recordsorread_lecordsmethod. Each of these methods receives same aguments assearchorreadmethod respectively. But passingcountargument forsearch\_recordswill cause error. Main difference betwen these methods
in usingRecordclass
instead ofdictfor each record had been read. Record class provides some orm-like abilities for records,
allowing for example access fields as attributes and provide mechanisms
to lazily fetch related fields.>>>sale_orders=sale_order_obj.search_records([('state','=','done')])>>>sale_orders[0]R(sale.order,9)[SO0011]>>>>>># So we have list of Record objects. Let's check what they are>>>so=sale_orders[0]>>>so.id9>>>so.nameSO0011>>>so.partner_idR(res.partner,9)[BetterCorp]>>>>>>so.partner_id.nameBetterCorp>>>so.partner_id.activeTrueAdditional featuresPluginsIn version 0.4 plugin system was completly refactored. At this version
we start usingextend_melibrary to build extensions and plugins easily.Plugins are usual classes that provides functionality that should be available
atdb.plugins.*point, implementing logic not related to core system.For more information seesource
codeanddocumentation