Skip to main content

pipeline status coverage report

: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
  • Contract - Contract information
  • ProductCatalog - Sales product variants
  • CoopAgreement - lit for coop agreement code

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 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 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"

Search Contracts by partner's VAT number

>>> from odoo_somconnexio_python_client.resources.contract import Contract
>>>
>>> contracts = Contract.search_by_customer_vat(vat="XXXX")
>>> contracts[0].id
123
>>> contracts[0].phone_number
"972445566"

Create new mapper

Create 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"
      }
    }
  ]
}

Development

Setup environment

  1. Install pyenv
curl https://pyenv.run | bash
  1. Build the Python version
pyenv install  3.8.13
  1. Create a virtualenv
pyenv virtualenv 3.8.13 odoo-somconnexio-python-client
  1. Install dependencies
pyenv exec pip install -r requirements-dev.txt
  1. Install pre-commit hooks
pyenv exec pre-commit install

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 actually call the Odoo local client in order to create or rewrite cassettes using the next pyenv commands, we need to first change the conftest.py file 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 the Configuration Environment section
  • Execute the tests using pytest command:
  • If you are writing a new test 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 pre-commit to execute Black as formatter.

Release process

Update CHANGELOG.md following this steps:

  1. Add any entries missing from merged merge requests.
  2. Duplicate the [Unreleased] header.
  3. 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:

  1. Update the __version__ var in __init__.py matching the version you specified in the CHANGELOG.
  2. Open a merge request with these changes for the team to approve
  3. Merge it, add a git tag on that merge commit and push it.
  4. Once the pipeline has successfully passed, go approve the publish step.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

odoo_somconnexio_python_client-0.1.53.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odoo_somconnexio_python_client-0.1.53-py2.py3-none-any.whl (48.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file odoo_somconnexio_python_client-0.1.53.tar.gz.

File metadata

File hashes

Hashes for odoo_somconnexio_python_client-0.1.53.tar.gz
Algorithm Hash digest
SHA256 2604334a31f2cd133899709d6ea6cbefa2f4a28348ebd586b941827f048c7824
MD5 09f16fb15c821e03298ca75a9d7d3d15
BLAKE2b-256 42bf5219b6befcc880306be87c0ad66d866b4ed18b93d7f5e43215a282c66c7f

See more details on using hashes here.

File details

Details for the file odoo_somconnexio_python_client-0.1.53-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_somconnexio_python_client-0.1.53-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ce8a6772bbd780d7e0bd7e018eff57ca84b645d59f9e7065dfa86e18484361ea
MD5 0ff18e44ffe5810d3091087d5fc90b54
BLAKE2b-256 583f5531067476cda67ad1793980c3c8764258306113be248b7278a505212182

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page