Skip to content
Snippets Groups Projects
Commit 0bde6bff authored by Daniel Palomar's avatar Daniel Palomar
Browse files

Add DiscoveryChannel resource with search method

parent 2f9f38a4
No related branches found
No related tags found
1 merge request!3Discovery channel resource management.
......@@ -11,6 +11,7 @@ More info about the customizations in [SomConnexio Odoo module](https://gitlab.c
* SubscriptionRequest - Customer order
* CRMLead - Service order
* Provider - Service providers
* DiscoveryChannel
* Partner - Customer information
## Installation
......
from odoo_somconnexio_python_client.client import Client
class DiscoveryChannel:
_url_path = "/discovery-channel"
def __init__(self, id, name):
self.id = id
self.name = name
@classmethod
def search(cls):
"""
Return a list with all the discovery
channels allowed in Odoo.
:return: List of discovery channels
"""
response_data = Client().get("{}".format(cls._url_path))
discovery_channels = []
for dc in response_data.get("discovery_channels"):
discovery_channels.append(cls(**dc))
return discovery_channels
......@@ -75,6 +75,7 @@ class SubscriptionRequestFromPartnerForm:
"vat": self.partner_data.get("vat_number"),
"payment_type": self._payment_type(),
"nationality": self.partner_data.get("nationality"),
"discovery_channel_id": int(self.partner_data.get("discovery_channel")),
# TODO: Add to the Odoo API/Model
"sponsor_vat": self.partner_data.get("partner_number"),
......
interactions:
- request:
body: null
headers:
API-KEY:
- 5b512e2f-1b02-4fdf-b49d-4dddf68b3002
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- python-requests/2.22.0
method: GET
uri: http://odoo-sc.local:8069/api/discovery-channel
response:
body:
string: !!python/unicode '{"discovery_channels": [{"id": 1, "name": "Fires /
Xerrades"}, {"id": 2, "name": "Altres cooperatives / Xarxes d''economia solid\u00e0ria"},
{"id": 3, "name": "Xarxes socials (Facebook, Twitter, Instagram, Linkedin,
etc)"}, {"id": 4, "name": "Cercadors d''Internet (Google, Yahoo, etc)"}, {"id":
5, "name": "Mitjans de comunicaci\u00f3 tradicionals (premsa, r\u00e0dio,
televisi\u00f3, etc)"}, {"id": 6, "name": "Recomenat per un soci/amic/conegut"},
{"id": 7, "name": "Opcions"}, {"id": 8, "name": "Altres"}]}'
headers:
access-control-allow-methods:
- GET
access-control-allow-origin:
- None
content-length:
- '508'
content-type:
- application/json
date:
- Wed, 09 Dec 2020 15:11:23 GMT
server:
- Werkzeug/0.11.15 Python/3.7.7
set-cookie:
- session_id=6e3c37cd4f61bd56aa6274cd73af1f20cc93063e; Expires=Tue, 09-Mar-2021
15:11:23 GMT; Max-Age=7776000; HttpOnly; Path=/
status:
code: 200
message: OK
version: 1
from __future__ import unicode_literals # support both Python2 and 3
import pytest
import unittest2 as unittest
from odoo_somconnexio_python_client.resources.discovery_channel import DiscoveryChannel
class DiscoveryChannelTests(unittest.TestCase):
@pytest.mark.vcr()
def test_search(self):
discovery_channels = DiscoveryChannel.search()
for dc in discovery_channels:
self.assertIsInstance(dc, DiscoveryChannel)
......@@ -28,6 +28,7 @@ class SubscriptionRequestTests(unittest.TestCase):
"country": "ES",
},
"lang": "es_CA",
"discovery_channel_id": 4,
"share_product": 0,
"iban": "ES6621000418401234567891",
"vat": "73420857G",
......
......@@ -97,6 +97,7 @@ class FakePartnerForm(TrytonFactory):
# To transform to models
"nationality": self.country.code,
# To investigate
"discovery_channel": 4,
"contribute_somconnexio_option": "0",
"sex": "male",
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment