Python wrapper for SomConnexio's Odoo (using REST API)
Project description
: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 in SomConnexio Odoo module.
Resources
- SubscriptionRequest - Customer order
- CRMLead - Service order
- Provider - Service providers
- DiscoveryChannel
- Partner - Customer information
Installation
$ pip install odoo-somconnexio-python-client
Configuration Environment
You need define the Odoo API-KEY and URL as environment variables. You need define:
ODOO_BASEURL=<YOUR ODOO HOST>/api
ODOO_APIKEY=<YOUR OC USER>
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 in Auth API Key Odoo module.
Usage
Search providers by service
>>> from odoo_somconnexio_python_client.resources.provider import Provider
>>>
>>> mobile_providers = Provider.mobile_list()
>>> mobile_providers[0].id
123
>>> mobile_providers[0].name
"SomConnexió"
Get Partner with ref
>>> from odoo_somconnexio_python_client.resources.partner import Partner
>>>
>>> partner = Partner.get(1234)
>>> partner.id
123
>>> partner.ref
"1234"
Search Partner by VAT number
>>> from odoo_somconnexio_python_client.resources.partner import Partner
>>>
>>> partner = Partner.search_by_vat(vat="XXXX")
>>> partner.id
123
>>> partner.ref
"1234"
Create new mapper
Create a class that expose a dict objecti 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"
}
}
]
}
Development
Test the HTTP request
We 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 add a new test:
- Exepose the needes envvars. Looks the Configuration Environment section
- Execute the tests using
pytest
command: - If you are writing a new tests that is making requests, you should run:
$ pytest --record-mode=once path/to/your/test
- You 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/test
- Add the new
cassetes
to the commit and push them. - The CI uses the cassetes to emulate the HTTP response in the test.
Run test suite
$ tox
Formatting
We use Black as formatter.
First to commit, tun the black
command:
$ black .
All done! ✨ 🍰 ✨
29 files left unchanged.
Release process
Update CHANGELOG.md following this steps:
- Add any entries missing from merged merge requests.
- Duplicate the
[Unreleased]
header. - Replace the second
Unreleased
with 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 insetup.py
matching the version you specified in the CHANGELOG. - Open a merge request with these changes for the team to approve
- Merge it, add a git tag on that merge commit and push it.
- Once the pipeline has successfully passed, go approve the
publish
step.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for odoo-somconnexio-python-client-0.1.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 760f461c482ba824fccaf2da755cbd67d8180e7a0b1518ba81b937867246295f |
|
MD5 | 83c3fb367bc9fe51083b33a43963e0df |
|
BLAKE2b-256 | 1d215a6bb6dbc43c27fc8e36db0761908c0a65cc100c00b18869c44ad108a5e3 |
Hashes for odoo_somconnexio_python_client-0.1.20-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e40e78b16f031065f6ff02a16e9e110839ee08f050d2d8baf2085a0d0905c449 |
|
MD5 | df5962788a29a9e9dd0e5a0eb77449b9 |
|
BLAKE2b-256 | 2251baf60f1bdd56179b05511700fe45ff4adf40b097d55e939cd7d6df6cadbc |