Package: odoo-xmlrpc-wrapper
Odoo XMLRPC WrapperA small wrapper for oversimplifying CRUD operations and connecting to the Odoo External API
with the Python xmlrpc module.IndexGetting StartedInstalling via pipA Simple ConnectionCRUD OperationsCreateReadUpdateDeleteMiscellaneousSearchSearch and ReadCountGet FieldsA Little DetailBot InstanceActive ModelContributionLicenseGetting StartedInstalling via pippipinstallodoo-xmlrpc-wrapperA Simple Connectionfromodoo_xmlrpc_wrapperimportodoo_xmlrpc_wrapperasoxwHOST="odoo.myhost.com"DB="my_test_db"USERLOGIN="mymailtologin@odoo.com"PASSWORD="mypass"bot=oxw.Bot(HOST,DB,USERLOGIN,PASSWORD)Prints:Successfully Logged
Name: Mitchell Admin
DB: my_test_db
HOST: https://odoo.myhost.com
VERSION: saas~16.1CRUD OperationsOnce the model to be processed in the CRUD functions is entered, the following other
You do not need to specify the model again as long as the model does not change to
the operation functions.Createbot.create("res.partner",{"name":"John Doe"})Readbot.read(ids=[84],fields=["name"])Returns:[{"id": 84, "name": "John Doe"}]Updatebot.update(the_id=84,the_obj={"name":"Jane Doe"})Deletebot.delete(ids=[84])MiscellaneousSearchbot.search(constraints=[("name","=","Mitchell Admin")])Returns:[2]Search and Readbot.search_read(constraints=[("name","=","Mitchell Admin")])Returns:[{'id': 2, 'name': 'Mitchell Admin'}]Countbot.count()Returns:78Get Fieldsbot.get_fields("res.partner.title",attributes=["type"])Output:{
  "name": {"type": "char"},
  "shortcut": {"type": "char"},
  "id": {"type": "integer"},
  "display_name": {"type": "char"},
  "create_uid": {"type": "many2one"},
  "create_date": {"type": "datetime"},
  "write_uid": {"type": "many2one"},
  "write_date": {"type": "datetime"},
}A Little DetailBot Instancebot=oxw.Bot(HOST,DB,USERLOGIN,PASSWORD)# Simple Connectionbot=oxw.Bot(HOST,DB,USERLOGIN,PASSWORD,secured=False)# For http:// (no-ssl) (localhost)bot=oxw.Bot(test=True)# For XMLRPC Tests from Odoo saasIf you are going to connect to a host with an unencrypted http protocol such as localhost,secured=Falsemust be specified.test=Trueallows you to connect to one of Odoo's own xmlrpc test servers. Odoo assigns
you a random host, database, user and password from the demo servers. You don't need other
attributes when test option is selected.Active ModelThe default model when a bot instance is initialized is"res.users". So when you commandbot.count()it returns active users total as an integer.You can assign the active model at any time withbot.model = "model.name"or when calling
any next method, such asbot.count("res.partner")ContributionFeel free to contribute. This project needs a fine exception handling.LicenseMIT LicenseCopyright 2023 Cagatay URESINPermission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the “Software”), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.