Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
improved crvs_data_source.xml, removed create_data_source function, f…
Browse files Browse the repository at this point in the history
…ix fetch button
  • Loading branch information
reichie020212 committed Dec 14, 2023
1 parent 1350021 commit df6a6ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 40 deletions.
44 changes: 20 additions & 24 deletions spp_import_dci_api/data/crvs_data_source.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<function model="spp.data.source" name="create_data_source">
<value
model="spp.data.source"
eval="{
'name': 'CRVS',
'url': 'https://dci.opencrvs.lab.cdpi.dev',
'auth_type':'bearer_authentication',
'paths': [
{
'name': 'Registry Sync Search',
'path': '/registry/sync/search',
},
{
'name': 'Authentication',
'path': '/oauth2/client/token',
},
{
'name': 'Location',
'path': '/.well-known/locations.json',
}
]
}"
/>
</function>
<record id="spp_crvs_data_source" model="spp.data.source">
<field name="name">CRVS</field>
<field name="url">https://dci.opencrvs.lab.cdpi.dev</field>
<field name="auth_type">bearer_authentication</field>
</record>
<record id="spp_crvs_registry_path" model="spp.data.source.path">
<field name="data_source_id" eval="ref('spp_import_dci_api.spp_crvs_data_source')" />
<field name="key">Registry Sync Search</field>
<field name="value">/registry/sync/search</field>
</record>
<record id="spp_crvs_oauth2_path" model="spp.data.source.path">
<field name="data_source_id" eval="ref('spp_import_dci_api.spp_crvs_data_source')" />
<field name="key">Authentication</field>
<field name="value">/oauth2/client/token</field>
</record>
<record id="spp_crvs_location_path" model="spp.data.source.path">
<field name="data_source_id" eval="ref('spp_import_dci_api.spp_crvs_data_source')" />
<field name="key">Location</field>
<field name="value">/.well-known/locations.json</field>
</record>
</odoo>
2 changes: 1 addition & 1 deletion spp_import_dci_api/models/fetch_crvs_beneficiary.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def get_data_source_paths(self):
paths = {}

for path_id in self.data_source_id.data_source_path_ids:
paths[path_id.name] = path_id.path
paths[path_id.key] = path_id.value

if constants.DATA_SOURCE_SEARCH_PATH_NAME not in paths:
raise ValidationError(
Expand Down
16 changes: 1 addition & 15 deletions spp_registry_data_source/models/data_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import api, fields, models
from odoo import fields, models


class SppDataSource(models.Model):
Expand Down Expand Up @@ -32,20 +32,6 @@ class SppDataSource(models.Model):
("name_uniq", "unique(name)", "The name of the data source must be unique !"),
]

@api.model
@api.returns("self", lambda value: value.id)
def create_data_source(self, vals):
data_source_id = self.search([("name", "=", vals.get("name"))], limit=1)
if data_source_id:
return data_source_id
paths, path_create_vals = vals.pop("paths", []), []
for path in paths:
path_create_vals.append(
(0, 0, {"key": path.get("name"), "value": path.get("path")})
)
vals["data_source_path_ids"] = path_create_vals
return self.create(vals)

def get_field_mapping_key_value_pair(self):
return self.data_source_field_mapping_ids.get_mapping()

Expand Down

0 comments on commit df6a6ff

Please sign in to comment.