Package: odoo-somconnexio-python-client
:warning: WORK IN PROGRESS :warning:This library is a Python wrapper for accessing Somconnexio's Odoo (Odoo v12 with customizations).
More info about the customizations inSomConnexio Odoo module.ResourcesSubscriptionRequest - Customer orderCRMLead - Service orderProvider - Service providersDiscoveryChannelPartner - Customer informationContract - Contract informationInstallation$ pip install odoo-somconnexio-python-clientConfiguration EnvironmentYou need define the Odoo API-KEY and URL as environment variables. You need define:ODOO_BASEURL=<YOUR ODOO HOST>/api
ODOO_APIKEY=<YOUR ODOO API KEY>If this envvars are not defined, a exception will be raised with the name of the envvar not defined.
More info about the API-KEY inAuth API KeyOdoo module.UsageSearch providers by service>>>fromodoo_somconnexio_python_client.resources.providerimportProvider>>>>>>mobile_providers=Provider.mobile_list()>>>mobile_providers[0].id123>>>mobile_providers[0].name"SomConnexió"Get Partner with ref>>>fromodoo_somconnexio_python_client.resources.partnerimportPartner>>>>>>partner=Partner.get(1234)>>>partner.id123>>>partner.ref"1234"Search Partner by VAT number>>>fromodoo_somconnexio_python_client.resources.partnerimportPartner>>>>>>partner=Partner.search_by_vat(vat="XXXX")>>>partner.id123>>>partner.ref"1234"Search Contracts by partner's VAT number>>>fromodoo_somconnexio_python_client.resources.contractimportContract>>>>>>contracts=Contract.search_by_customer_vat(vat="XXXX")>>>contracts[0].id123>>>contracts[0].phone_number"972445566"Create new mapperCreate a class that exposes a dict object with the next structure:Create a SubscriptionRequest{"name":"string","email":"string","ordered_parts":0,"share_product":0,"address":{"street":"string","street2":"string","zip_code":"string","city":"string","country":"string","state":"string"},"lang":"string","iban":"string","vat":"string","coop_agreement":"string","voluntary_contribution":0,"nationality":"string","payment_type":"string"}Create a CRMLead{"iban":"string","subscription_request_id":0,"partner_id":0,"lead_line_ids":[{"product_code":"string","broadband_isp_info":{"phone_number":"string","type":"string","delivery_address":{"street":"string","street2":"string","zip_code":"string","city":"string","country":"string","state":"string"},"previous_provider":0,"previous_owner_vat_number":"string","previous_owner_name":"string","previous_owner_first_name":"string","service_address":{"street":"string","street2":"string","zip_code":"string","city":"string","country":"string","state":"string"},"previous_service":"string","keep_phone_number":true,"change_address":true},"mobile_isp_info":{"phone_number":"string","type":"string","delivery_address":{"street":"string","street2":"string","zip_code":"string","city":"string","country":"string","state":"string"},"previous_provider":0,"previous_owner_vat_number":"string","previous_owner_name":"string","previous_owner_first_name":"string","icc":"string","icc_donor":"string","previous_contract_type":"string"}}]}DevelopmentSetup environmentInstallpyenvcurlhttps://pyenv.run|bashBuild the Python versionpyenvinstall3.8.13Create a virtualenvpyenvvirtualenv3.8.13odoo-somconnexio-python-clientInstall dependenciespyenvexecpipinstall-rrequirements-dev.txtInstall pre-commit hookspyenvexecpre-commitinstallTest the HTTP requestWe are using the HTTP recording plugin of Pytest:pytest-recording.With VRC we can catch the HTTP responses and then, execute the tests using them.To actually call the Odoo local client in order to create or rewrite cassettes using the next pyenv commands, we need to first change theconftest.pyfile and temporally provide the actual Odoo API-KEY.monkeypatch.setenv("ODOO_APIKEY", "<ACTUAL_ODOO_APIKEY>")⚠️Do not commit this change!To add a new test:Expose the needed envvars. Look for them at theConfiguration Environment sectionExecute the tests usingpytestcommand:If you are writing a new test that is making requests, you should run:$ pytest --record-mode=once path/to/your/testYou might need to record requests for an specific tests. In that case make sure to only run the tests affected and run$ pytest --record-mode=rewrite path/to/your/testAdd the newcassetesto the commit and push them.The CI uses the cassetes to emulate the HTTP response in the test.Run test suite$ toxFormattingWe usepre-committo executeBlackas formatter.Release processUpdate CHANGELOG.md following this steps:Add any entries missing from merged merge requests.Duplicate the[Unreleased]header.Replace the secondUnreleasedwith a version number followed by the current date. Copy the exact format from previous releases.Then, you can release and publish the package to PyPi:Update the__version__var in__init__.pymatching the version you specified in the CHANGELOG.Open a merge request with these changes for the team to approveMerge it, add a git tag on that merge commit and push it.Once the pipeline has successfully passed, go approve thepublishstep.