diff --git a/iap_alternative_provider/README.rst b/iap_alternative_provider/README.rst new file mode 100644 index 00000000000..7d54e5c85d3 --- /dev/null +++ b/iap_alternative_provider/README.rst @@ -0,0 +1,93 @@ +======================== +IAP Alternative Provider +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a553eb511075a2b7c71156fdfec49709339b37077904d0b585a91acee72fd9ff + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/18.0/iap_alternative_provider + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-iap_alternative_provider + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Abstract module that provide base functionality for implementing +alternative provider for the IAP application. + +An example of alternative provider can be found in [the +connector-telephony +repository](https://github.com/OCA/connector-telephony), with the module +**sms_ovh_http** (sending sms with ovh instead of odoo iap) + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Akretion + +Contributors +------------ + +- Sébastien BEAU +- Trobz (https://www.trobz.com) + + - Tuan Nguyen tuanna@trobz.com + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-sebastienbeau| image:: https://github.com/sebastienbeau.png?size=40px + :target: https://github.com/sebastienbeau + :alt: sebastienbeau + +Current `maintainer `__: + +|maintainer-sebastienbeau| + +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/iap_alternative_provider/__init__.py b/iap_alternative_provider/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /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 00000000000..bc5de32e255 --- /dev/null +++ b/iap_alternative_provider/__manifest__.py @@ -0,0 +1,19 @@ +# 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": "18.0.1.0.0", + "category": "Tools", + "website": "https://github.com/OCA/server-tools", + "author": "Akretion, Odoo Community Association (OCA)", + "maintainers": ["sebastienbeau"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["iap"], + "data": ["views/iap_account_view.xml"], +} diff --git a/iap_alternative_provider/i18n/ca.po b/iap_alternative_provider/i18n/ca.po new file mode 100644 index 00000000000..efebaaf4488 --- /dev/null +++ b/iap_alternative_provider/i18n/ca.po @@ -0,0 +1,50 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * iap_alternative_provider +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__assigned_attachment_ids +msgid "Assigned Attachments" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model,name:iap_alternative_provider.model_iap_account +msgid "IAP Account" +msgstr "" + +#. module: iap_alternative_provider +#: model_terms:ir.ui.view,arch_db:iap_alternative_provider.iap_account_view_form +msgid "Info" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__name +msgid "Name" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields.selection,name:iap_alternative_provider.selection__iap_account__provider__odoo +msgid "Odoo IAP" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__provider +msgid "Provider" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__smart_search +msgid "Smart Search" +msgstr "" diff --git a/iap_alternative_provider/i18n/es.po b/iap_alternative_provider/i18n/es.po new file mode 100644 index 00000000000..f590136a2da --- /dev/null +++ b/iap_alternative_provider/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * iap_alternative_provider +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-14 19:34+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__assigned_attachment_ids +msgid "Assigned Attachments" +msgstr "Archivos Adjuntos Asignados" + +#. module: iap_alternative_provider +#: model:ir.model,name:iap_alternative_provider.model_iap_account +msgid "IAP Account" +msgstr "Cuenta IAP" + +#. module: iap_alternative_provider +#: model_terms:ir.ui.view,arch_db:iap_alternative_provider.iap_account_view_form +msgid "Info" +msgstr "Info" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__name +msgid "Name" +msgstr "Nombre" + +#. module: iap_alternative_provider +#: model:ir.model.fields.selection,name:iap_alternative_provider.selection__iap_account__provider__odoo +msgid "Odoo IAP" +msgstr "IAP de Odoo" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__provider +msgid "Provider" +msgstr "Proveedor" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__smart_search +msgid "Smart Search" +msgstr "Búsqueda Inteligente" diff --git a/iap_alternative_provider/i18n/iap_alternative_provider.pot b/iap_alternative_provider/i18n/iap_alternative_provider.pot new file mode 100644 index 00000000000..e8dba8577ed --- /dev/null +++ b/iap_alternative_provider/i18n/iap_alternative_provider.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * iap_alternative_provider +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: iap_alternative_provider +#: model:ir.model,name:iap_alternative_provider.model_iap_account +msgid "IAP Account" +msgstr "" + +#. module: iap_alternative_provider +#: model_terms:ir.ui.view,arch_db:iap_alternative_provider.iap_account_view_form +msgid "Info" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields.selection,name:iap_alternative_provider.selection__iap_account__provider__odoo +msgid "Odoo IAP" +msgstr "" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__provider +msgid "Provider" +msgstr "" diff --git a/iap_alternative_provider/i18n/it.po b/iap_alternative_provider/i18n/it.po new file mode 100644 index 00000000000..4e976210d54 --- /dev/null +++ b/iap_alternative_provider/i18n/it.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * iap_alternative_provider +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-02-05 09:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__assigned_attachment_ids +msgid "Assigned Attachments" +msgstr "Allegati assegnati" + +#. module: iap_alternative_provider +#: model:ir.model,name:iap_alternative_provider.model_iap_account +msgid "IAP Account" +msgstr "Account IAP" + +#. module: iap_alternative_provider +#: model_terms:ir.ui.view,arch_db:iap_alternative_provider.iap_account_view_form +msgid "Info" +msgstr "Informazioni" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__name +msgid "Name" +msgstr "Nome" + +#. module: iap_alternative_provider +#: model:ir.model.fields.selection,name:iap_alternative_provider.selection__iap_account__provider__odoo +msgid "Odoo IAP" +msgstr "IAP Odoo" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__provider +msgid "Provider" +msgstr "Provider" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__smart_search +msgid "Smart Search" +msgstr "Ricerca intelligente" diff --git a/iap_alternative_provider/i18n/zh_CN.po b/iap_alternative_provider/i18n/zh_CN.po new file mode 100644 index 00000000000..e25d361c984 --- /dev/null +++ b/iap_alternative_provider/i18n/zh_CN.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * iap_alternative_provider +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-06-16 17:40+0000\n" +"Last-Translator: xtanuiha \n" +"Language-Team: none\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 4.17\n" + +#. module: iap_alternative_provider +#: model:ir.model,name:iap_alternative_provider.model_iap_account +msgid "IAP Account" +msgstr "IAP账户" + +#. module: iap_alternative_provider +#: model_terms:ir.ui.view,arch_db:iap_alternative_provider.iap_account_view_form +msgid "Info" +msgstr "信息" + +#. module: iap_alternative_provider +#: model:ir.model.fields.selection,name:iap_alternative_provider.selection__iap_account__provider__odoo +msgid "Odoo IAP" +msgstr "Odoo IAP" + +#. module: iap_alternative_provider +#: model:ir.model.fields,field_description:iap_alternative_provider.field_iap_account__provider +msgid "Provider" +msgstr "提供者" diff --git a/iap_alternative_provider/models/__init__.py b/iap_alternative_provider/models/__init__.py new file mode 100644 index 00000000000..966d7e1afb5 --- /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 00000000000..9f94d23389a --- /dev/null +++ b/iap_alternative_provider/models/iap_account.py @@ -0,0 +1,37 @@ +# 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" + + provider = fields.Selection([("odoo", "Odoo IAP")], required=True, default="odoo") + + def _get_service_from_provider(self): + """In case that the provider only propose one service you can + return the service in your 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_id != service: + record.service_id = service + + @api.onchange("provider") + def onchange_provider(self): + self._set_service_from_provider() + + @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): + res = super().write(vals) + self._set_service_from_provider() + return res diff --git a/iap_alternative_provider/pyproject.toml b/iap_alternative_provider/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/iap_alternative_provider/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/iap_alternative_provider/readme/CONTRIBUTORS.md b/iap_alternative_provider/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..63513cd2735 --- /dev/null +++ b/iap_alternative_provider/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- Sébastien BEAU \<\> +- Trobz (https://www.trobz.com) + - Tuan Nguyen diff --git a/iap_alternative_provider/readme/DESCRIPTION.md b/iap_alternative_provider/readme/DESCRIPTION.md new file mode 100644 index 00000000000..ccd7bd68dee --- /dev/null +++ b/iap_alternative_provider/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +Abstract module that provide base functionality for implementing +alternative provider for the IAP application. + +An example of alternative provider can be found in \[the +connector-telephony +repository\](), with the +module **sms_ovh_http** (sending sms with ovh instead of odoo iap) diff --git a/iap_alternative_provider/static/description/icon.png b/iap_alternative_provider/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/iap_alternative_provider/static/description/icon.png differ diff --git a/iap_alternative_provider/static/description/index.html b/iap_alternative_provider/static/description/index.html new file mode 100644 index 00000000000..5d0ead77902 --- /dev/null +++ b/iap_alternative_provider/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +IAP Alternative Provider + + + +
+

IAP Alternative Provider

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

+

Abstract module that provide base functionality for implementing +alternative provider for the IAP application.

+

An example of alternative provider can be found in [the +connector-telephony +repository](https://github.com/OCA/connector-telephony), with the module +sms_ovh_http (sending sms with ovh instead of odoo iap)

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

sebastienbeau

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/iap_alternative_provider/tests/__init__.py b/iap_alternative_provider/tests/__init__.py new file mode 100644 index 00000000000..caa11bc675f --- /dev/null +++ b/iap_alternative_provider/tests/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2022 Moka Tourisme (https://www.mokatourisme.fr). +# @author Pierre Verkest +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_iap_account diff --git a/iap_alternative_provider/tests/test_iap_account.py b/iap_alternative_provider/tests/test_iap_account.py new file mode 100644 index 00000000000..9eb9a1b5641 --- /dev/null +++ b/iap_alternative_provider/tests/test_iap_account.py @@ -0,0 +1,70 @@ +# Copyright 2022 Moka Tourisme (https://www.mokatourisme.fr). +# @author Pierre Verkest +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from unittest import mock + +from odoo.tests import TransactionCase + + +class IapAccountCase(TransactionCase): + @classmethod + def setUpClass(cls): + res = super().setUpClass() + + cls.lead_service = cls.env.ref("iap.iap_service_reveal") + cls.other_service = cls.env["iap.service"].create( + { + "name": "Other Service", + "technical_name": "other-service", + "description": "Other Service", + "unit_name": "Credits", + "integer_balance": True, + } + ) + + return res + + def test_create_odoo_iap(self): + account = self.env["iap.account"].create( + { + "name": "Odoo IAP", + "provider": "odoo", + "service_id": self.lead_service.id, + } + ) + self.assertEqual(account.service_id, self.lead_service) + + def test_create_with_mock(self): + with mock.patch( + "odoo.addons.iap_alternative_provider.models." + "iap_account.IapAccount._get_service_from_provider", + return_value=self.lead_service, + ): + account = self.env["iap.account"].create( + { + "name": "Odoo IAP", + "provider": "odoo", + "service_id": self.other_service.id, + } + ) + self.assertEqual(account.service_id, self.lead_service) + + def test_write_odoo_iap(self): + account = self.env["iap.account"].create( + { + "name": "Odoo IAP", + "provider": "odoo", + "service_id": self.lead_service.id, + } + ) + account.write({"service_id": self.other_service.id}) + self.assertEqual(account.service_id, self.other_service) + account.write({"service_id": self.lead_service.id}) + with mock.patch( + "odoo.addons.iap_alternative_provider.models." + "iap_account.IapAccount._get_service_from_provider", + return_value=self.lead_service, + ): + account.write({"service_id": self.other_service.id}) + self.assertEqual(account.service_id, self.lead_service) 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 00000000000..a23888cb1c5 --- /dev/null +++ b/iap_alternative_provider/views/iap_account_view.xml @@ -0,0 +1,23 @@ + + + + iap.account + + + + + + + + + + provider != 'odoo' + + + +