diff --git a/.travis.yml b/.travis.yml index fa0c7a785..f6bcd31fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ env: - TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="database_cleanup" MAKEPOT="1" - TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="module_analysis" MAKEPOT="1" - install: - git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} diff --git a/iap_alternative_provider/__init__.py b/iap_alternative_provider/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/iap_alternative_provider/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/iap_alternative_provider/__manifest__.py b/iap_alternative_provider/__manifest__.py new file mode 100644 index 000000000..72405dcfc --- /dev/null +++ b/iap_alternative_provider/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright 2020 Akretion (https://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +{ + "name": "IAP Alternative Provider", + "summary": "Base module for providing alternative provider for iap apps", + "version": "12.0.1.0.0", + "category": "Tools", + "website": "http://github.com/OCA/server-tools", + "author": "Akretion, Odoo Community Association (OCA)", + "maintainers": ["sebastienbeau"], + "license": "AGPL-3", + "application": False, + "installable": True, + "external_dependencies": {"python": [], "bin": []}, + "depends": ["iap", "server_environment"], + "data": ["views/iap_account_view.xml"], + "demo": [], + "qweb": [], +} diff --git a/iap_alternative_provider/models/__init__.py b/iap_alternative_provider/models/__init__.py new file mode 100644 index 000000000..966d7e1af --- /dev/null +++ b/iap_alternative_provider/models/__init__.py @@ -0,0 +1 @@ +from . import iap_account diff --git a/iap_alternative_provider/models/iap_account.py b/iap_alternative_provider/models/iap_account.py new file mode 100644 index 000000000..aa8bf5436 --- /dev/null +++ b/iap_alternative_provider/models/iap_account.py @@ -0,0 +1,42 @@ +# Copyright 2020 Akretion (https://www.akretion.com). +# @author Sébastien BEAU +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class IapAccount(models.Model): + _inherit = ["iap.account", "server.env.mixin"] + _name = "iap.account" + + name = fields.Char() + provider = fields.Selection([("odoo", "Odoo IAP")], required=True, default="odoo") + + @property + def _server_env_fields(self): + return { + "provider": {}, + "account_token": {}, + } + + def _get_service_from_provider(self): + """In case that the provider only propose one service you can + return the service_name in you module to simplify the user interface""" + return None + + def _set_service_from_provider(self): + for record in self: + service = record._get_service_from_provider() + if service and record.service_name != service: + record.service_name = service + + @api.model_create_multi + def create(self, vals_list): + record = super().create(vals_list) + record._set_service_from_provider() + return record + + def write(self, vals): + super().write(vals) + self._set_service_from_provider() + return True diff --git a/iap_alternative_provider/readme/CONTRIBUTORS.rst b/iap_alternative_provider/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9e0ae5f27 --- /dev/null +++ b/iap_alternative_provider/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sébastien BEAU diff --git a/iap_alternative_provider/readme/DESCRIPTION.rst b/iap_alternative_provider/readme/DESCRIPTION.rst new file mode 100644 index 000000000..f3b713a4a --- /dev/null +++ b/iap_alternative_provider/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +Abstract module that provide base fonctionnality for implementing alternative provider for the IAP application. + +An example of alternative provider can be found in the repository "connnector-telephony", with the module **sms_ovh_http** (sending sms with ovh instead of odoo iap) diff --git a/iap_alternative_provider/views/iap_account_view.xml b/iap_alternative_provider/views/iap_account_view.xml new file mode 100644 index 000000000..aa9d1e073 --- /dev/null +++ b/iap_alternative_provider/views/iap_account_view.xml @@ -0,0 +1,20 @@ + + + + iap.account + + + + + + + + + + {'invisible': [('provider', '!=', 'odoo')]} + + + +