Browse Source

[REF] emca: add AbsctractComponent for services

pull/116/head
robin.keunen 5 years ago
parent
commit
a2bdcb43c6
  1. 1
      easy_my_coop_api/services/__init__.py
  2. 21
      easy_my_coop_api/services/abstract_emc_service.py
  3. 5
      easy_my_coop_api/services/account_invoice_service.py
  4. 3
      easy_my_coop_api/services/ping_service.py
  5. 9
      easy_my_coop_api/services/subscription_request_service.py

1
easy_my_coop_api/services/__init__.py

@ -1,3 +1,4 @@
from . import abstract_emc_service
from . import ping_service
from . import subscription_request_service
from . import account_invoice_service

21
easy_my_coop_api/services/abstract_emc_service.py

@ -0,0 +1,21 @@
# Copyright 2019 Coop IT Easy SCRL fs
# Robin Keunen <robin@coopiteasy.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
# pylint: disable=consider-merging-classes-inherited
from odoo.addons.component.core import AbstractComponent
class BaseRestService(AbstractComponent):
_name = "emc.rest.service"
_inherit = "base.rest.service"
_collection = "emc.services"
_description = """
Base Rest Services
"""
def _one_to_many_to_dict(self, record):
if record:
return {"id": record.get_api_external_id(), "name": record.name}
else:
return {}

5
easy_my_coop_api/services/account_invoice_service.py

@ -19,10 +19,9 @@ _logger = logging.getLogger(__name__)
class AccountInvoiceService(Component):
_inherit = "base.rest.service"
_name = "account.invoice.services"
_name = "account.invoice.service"
_inherit = "emc.rest.service"
_usage = "invoice"
_collection = "emc.services"
_description = """
Account Invoice Services
"""

3
easy_my_coop_api/services/ping_service.py

@ -10,10 +10,9 @@ from odoo.addons.component.core import Component
class PingService(Component):
_inherit = "base.rest.service"
_inherit = "emc.rest.service"
_name = "emc.services"
_usage = "ping" # service_name
_collection = "emc.services"
_description = """
Ping services (test the api)
"""

9
easy_my_coop_api/services/subscription_request_service.py

@ -19,10 +19,9 @@ _logger = logging.getLogger(__name__)
class SubscriptionRequestService(Component):
_inherit = "base.rest.service"
_inherit = "emc.rest.service"
_name = "subscription.request.services"
_usage = "subscription-request"
_collection = "emc.services"
_description = """
Subscription Request Services
"""
@ -122,12 +121,6 @@ class SubscriptionRequestService(Component):
"capital_release_request": invoice_ids,
}
def _one_to_many_to_dict(self, record):
if record:
return {"id": record.get_api_external_id(), "name": record.name}
else:
return {}
def _get_country(self, code):
country = self.env["res.country"].search([("code", "=", code)])
if country:

Loading…
Cancel
Save