Skip to content

Commit

Permalink
Merge pull request #139 from mkumar-02/17.0-develop
Browse files Browse the repository at this point in the history
Migration 17.0: Migrated bank and registry api module.
  • Loading branch information
shibu-narayanan authored Jun 18, 2024
2 parents 3081ef6 + 99667e3 commit 5d0c44a
Show file tree
Hide file tree
Showing 48 changed files with 513 additions and 833 deletions.
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
exclude: |
(?x)
# NOT INSTALLABLE ADDONS
^g2p_bank_rest_api/|
^g2p_registry_addl_info_rest_api/|
^g2p_registry_rest_api/|
^g2p_registry_rest_api_extension_demo/|
# END NOT INSTALLABLE ADDONS
# Files and folders generated by bots, to avoid loops
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ Available addons
addon | version | maintainers | summary
--- | --- | --- | ---
[g2p_bank](g2p_bank/) | 17.0.1.0.0 | | G2P Registry: Bank Details
[g2p_bank_rest_api](g2p_bank_rest_api/) | 17.0.1.0.0 | | G2P Registry: Bank Details Rest API
[g2p_registry_addl_info](g2p_registry_addl_info/) | 17.0.1.0.0 | | G2P Registry: Additional Info
[g2p_registry_base](g2p_registry_base/) | 17.0.1.0.0 | | G2P Registry: Base
[g2p_registry_group](g2p_registry_group/) | 17.0.1.0.0 | | G2P Registry: Groups
[g2p_registry_individual](g2p_registry_individual/) | 17.0.1.0.0 | | G2P Registry: Individual
[g2p_registry_membership](g2p_registry_membership/) | 17.0.1.0.0 | | G2P Registry: Membership
[g2p_registry_rest_api](g2p_registry_rest_api/) | 17.0.1.0.0 | | G2P Registry: Rest API


Unported addons
---------------
addon | version | maintainers | summary
--- | --- | --- | ---
[g2p_bank_rest_api](g2p_bank_rest_api/) | 17.0.1.0.0 (unported) | | G2P Registry: Bank Details Rest API
[g2p_registry_addl_info_rest_api](g2p_registry_addl_info_rest_api/) | 17.0.1.0.0 (unported) | | G2P Registry: Additional Info REST API
[g2p_registry_rest_api](g2p_registry_rest_api/) | 17.0.1.0.0 (unported) | | G2P Registry: Rest API
[g2p_registry_rest_api_extension_demo](g2p_registry_rest_api_extension_demo/) | 17.0.1.0.0 (unported) | | G2P Registry: Rest API Extension Demo

[//]: # (end addons)
Expand Down
4 changes: 2 additions & 2 deletions g2p_bank_rest_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Part of OpenG2P Registry. See LICENSE file for full copyright and licensing details.
from . import models
from . import services
from . import schemas
from . import routers
2 changes: 1 addition & 1 deletion g2p_bank_rest_api/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"demo": [],
"images": [],
"application": False,
"installable": False,
"installable": True,
"auto_install": False,
}
28 changes: 0 additions & 28 deletions g2p_bank_rest_api/models/bank_details.py

This file was deleted.

7 changes: 0 additions & 7 deletions g2p_bank_rest_api/models/group_membership.py

This file was deleted.

11 changes: 0 additions & 11 deletions g2p_bank_rest_api/models/registrant.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from odoo.addons.component.core import AbstractComponent
from odoo import models


class ProcessGroupMixin(AbstractComponent):
class ProcessGroupMixin(models.AbstractModel):
_inherit = "process_group.rest.mixin"

def _process_group(self, group_info):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from odoo.addons.component.core import AbstractComponent
from odoo import models


class ProcessIndividualMixin(AbstractComponent):
class ProcessIndividualMixin(models.AbstractModel):
_inherit = "process_individual.rest.mixin"

def _process_individual(self, individual):
res = super()._process_individual(individual)
if individual.dict().get("bank_ids", None):
if individual.model_dump().get("bank_ids", None):
res["bank_ids"] = self._process_bank_ids(individual)
return res

def _process_bank_ids(self, registrant_info):
bank_ids = []
for rec in registrant_info.bank_ids:
bank_name = self.env["res.bank"].search([("name", "=", rec.bank_name)])
bank_name = self.env["res.bank"].sudo().search([("name", "=", rec.bank_name)])
if bank_name:
bank_name = bank_name[0]
else:
bank_name = self.env["res.bank"].create({"name": rec.bank_name})
bank_name = self.env["res.bank"].sudo().create({"name": rec.bank_name})
bank_ids.append(
(
0,
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions g2p_bank_rest_api/schemas/bank_details.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo.addons.g2p_registry_rest_api.schemas import naive_orm_model


class BankDetailsRequest(naive_orm_model.NaiveOrmModel):
bank_name: str = None
acc_number: str = None


class BankDetailsResponse(naive_orm_model.NaiveOrmModel):
bank_name: str = None
acc_number: str = None
9 changes: 9 additions & 0 deletions g2p_bank_rest_api/schemas/group_membership.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo.addons.g2p_registry_rest_api.schemas import group_membership

from . import bank_details


class GroupMembersInfoRequest(
group_membership.GroupMembersInfoRequest, extends=group_membership.GroupMembersInfoRequest
):
bank_ids: list[bank_details.BankDetailsRequest] | None
13 changes: 13 additions & 0 deletions g2p_bank_rest_api/schemas/registrant.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo.addons.g2p_registry_rest_api.schemas import registrant

from . import bank_details


class RegistrantAddlInfoRequest(registrant.RegistrantInfoRequest, extends=registrant.RegistrantInfoRequest):
bank_ids: list[bank_details.BankDetailsRequest] | None = None


class RegistrantAddlInfoResponse(
registrant.RegistrantInfoResponse, extends=registrant.RegistrantInfoResponse
):
bank_ids: list[bank_details.BankDetailsResponse] | None = None
7 changes: 4 additions & 3 deletions g2p_bank_rest_api/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down
6 changes: 3 additions & 3 deletions g2p_registry_rest_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Part of OpenG2P Registry. See LICENSE file for full copyright and licensing details.
from . import models
from . import services
from . import controllers
from . import http
from . import routers

# from . import http
from . import exceptions
7 changes: 3 additions & 4 deletions g2p_registry_rest_api/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
"license": "Other OSI approved licence",
"development_status": "Alpha",
"depends": [
"g2p_registry_base",
"g2p_registry_group",
"g2p_registry_individual",
"g2p_registry_membership",
"fastapi",
"extendable_fastapi",
],
"external_dependencies": {"python": ["extendable-pydantic", "pydantic"]},
"data": [
"data/fastapi_endpoint_registry.xml",
"security/g2p_security.xml",
"security/ir.model.access.csv",
],
"assets": {},
"demo": [],
"images": [],
"application": False,
"installable": False,
"installable": True,
"auto_install": False,
}
2 changes: 0 additions & 2 deletions g2p_registry_rest_api/controllers/__init__.py

This file was deleted.

8 changes: 0 additions & 8 deletions g2p_registry_rest_api/controllers/main.py

This file was deleted.

16 changes: 16 additions & 0 deletions g2p_registry_rest_api/data/fastapi_endpoint_registry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record model="fastapi.endpoint" id="fastapi_endpoint_registry">
<field name="name">OpenG2P FastAPI Endpoint</field>
<field name="description">This module implements OpenG2P APIs.</field>
<field name="app">registry</field>
<field name="root_path">/api/v1/registry</field>
</record>

<function
model="fastapi.endpoint"
name="sync_endpoint_id_with_registry"
eval="(ref('g2p_registry_rest_api.fastapi_endpoint_registry'),)"
/>

</odoo>
79 changes: 0 additions & 79 deletions g2p_registry_rest_api/http.py

This file was deleted.

7 changes: 2 additions & 5 deletions g2p_registry_rest_api/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Part of OpenG2P Registry. See LICENSE file for full copyright and licensing details.
from . import registrant
from . import group
from . import individual
from . import group_membership
from . import error_response

from . import fastapi_endpoint_registry
25 changes: 25 additions & 0 deletions g2p_registry_rest_api/models/fastapi_endpoint_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from fastapi import APIRouter

from odoo import api, fields, models

from ..routers.group import group_router
from ..routers.individual import individual_router


class G2PRegistryEndpoint(models.Model):
_inherit = "fastapi.endpoint"

app: str = fields.Selection(
selection_add=[("registry", "Registry Endpoint")], ondelete={"registry": "cascade"}
)

def _get_fastapi_routers(self) -> list[APIRouter]:
routers = super()._get_fastapi_routers()
if self.app == "registry":
routers.append(group_router)
routers.append(individual_router)
return routers

@api.model
def sync_endpoint_id_with_registry(self, endpoint_id):
return self.browse(endpoint_id).action_sync_registry()
Loading

0 comments on commit 5d0c44a

Please sign in to comment.