Package: odoo-connector-2
Easy Connector with Odoo ERP!This is a library that allow an easy and friendly connection with an Odoo ERP instance on Pyhton 3.xInstallation using PIP commandUse the command$pipinstallodoo-connector-2How to use connectfromodoo.connectorsimportOdooConnectorodoo=OdooConnector(endpoint='your-odoo-endpoint',dbname='your-odoo-dbname',username='your-odoo-user',password='your-odoo-password')uid=odoo.connect()Hot to add, edit and delete ( using the method write() )fromodoo.connectorsimportOdooConnectorodoo=OdooConnector(endpoint='your-odoo-endpoint',dbname='your-odoo-dbname',username='your-odoo-user',password='your-odoo-password')uid=odoo.connect()# create a new partnerdata=[{'name':'Test User','email':'test@domain.com'}]result=odoo.write(uid=uid,model='res.partner',action='create',data=data)# edit partnerid=1# change the value for the any do you wantdata=[[id],{'name':'Test User','email':'test@domain.com'}]result=odoo.write(uid=uid,model='res.partner',action='write',data=data)# delete partnerid=1# change the value for the any do you wantdata=[id]result=odoo.write(uid=uid,model='res.partner',action='unlink',data=data)# create a new userdata=[{'login':'test@domain.com','name':'Test User','password':'123456'}]result=odoo.write(uid=uid,model='res.users',action='signup',data=data)Hot to search, search_read and read ( using the method search() )fromodoo.connectorsimportOdooConnectorodoo=OdooConnector(endpoint='your-odoo-endpoint',dbname='your-odoo-dbname',username='your-odoo-user',password='your-odoo-password')uid=odoo.connect()query=[[['is_company','=',True],['customer','=',True]]]fields=['name','email','country_id']# using the search methodresult=odoo.search(uid=uid,model='res.partner',action='search',queries=query,parameters=None)# using the search with paginationparameters={'offset':5,'limit':10}result=odoo.search(uid=uid,model='res.partner',action='search',queries=query,parameters=parameters)# using the search_countodoo.search(uid=uid,model='res.partner',action='search_count',queries=query)# using the read methodids=odoo.search(uid=uid,model='res.partner',action='search',queries=query,parameters={'limit':1})iflen(ids)>0:result=self.odoo.search(uid=uid,model='res.partner',action='read',queries=ids,parameters={'fields':fields}formatted=True)# The "formatted" attribute allow format the result in a JSON object, this is a boolean attribute by default is False# using the search_read method with parameters.result=odoo.search(uid=uid,model='res.partner',action='search_read',queries=query,parameters={'fields':fields,'limit':2},formatted=True)The search and write methods were tested with all methods allowed on the External API Documentation from Odoo website
and the write() and search() methods can work with any methods from any models existing on Odoo instanceTo test any methods using unittestDownload or clone this repositoryEdit the attributes from the DummieData class (find this class on tests/unittests.py)run the follow command on the root directory.$python-munittest-vtests/unittest.pyThis is all, very very easy and friendly to work with Odoo from any Pyhton project using this library.Releases notes:1.0.0: Initial version1.0.1: README.md updated1.0.2: Bugs fixed related with the encoding defined on the ServerProxy connection.1.0.3: README.md updated.