diff --git a/payment_environment/__init__.py b/payment_environment/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/payment_environment/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/payment_environment/__manifest__.py b/payment_environment/__manifest__.py new file mode 100644 index 000000000..279798fe7 --- /dev/null +++ b/payment_environment/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2021 Camptocamp SA +# @author Iván Todorovich +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) + +{ + "name": "Payment Acquirers' configuration with server_environment", + "summary": "Configure payment acquirers with server_environment", + "category": "Tools", + "version": "13.0.1.0.0", + "license": "AGPL-3", + "author": "Camptocamp, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-env", + "maintainers": ["ivantodorovich"], + "depends": ["payment", "server_environment"], + "data": ["views/payment_acquirer.xml"], +} diff --git a/payment_environment/models/__init__.py b/payment_environment/models/__init__.py new file mode 100644 index 000000000..14289a55a --- /dev/null +++ b/payment_environment/models/__init__.py @@ -0,0 +1 @@ +from . import payment_acquirer diff --git a/payment_environment/models/payment_acquirer.py b/payment_environment/models/payment_acquirer.py new file mode 100644 index 000000000..0709c5adb --- /dev/null +++ b/payment_environment/models/payment_acquirer.py @@ -0,0 +1,23 @@ +# Copyright 2021 Camptocamp SA +# @author Iván Todorovich +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from odoo import models + + +class PaymentAcquirer(models.Model): + _name = "payment.acquirer" + _inherit = [ + "payment.acquirer", + "server.env.techname.mixin", + "server.env.mixin", + ] + + @property + def _server_env_fields(self): + base_fields = super()._server_env_fields + acquirer_fields = { + "state": {}, + } + acquirer_fields.update(base_fields) + return acquirer_fields diff --git a/payment_environment/readme/CONFIGURE.rst b/payment_environment/readme/CONFIGURE.rst new file mode 100644 index 000000000..b1030474d --- /dev/null +++ b/payment_environment/readme/CONFIGURE.rst @@ -0,0 +1,17 @@ +With this module installed, the payment acquirers are configured in +the `server_environment_files` module (which is a module you should provide, +see the documentation of `server_environment` for more information). + +In the configuration file of each environment, for each payment acquirer you +may use the section `[payment_acquirer.technical_name]` to configure the +acquirer values, where "technical_name" is the acquirer's `tech_name`. + +This module alone only lets you configure the `state` field, which allows to +set the acquirer's environment. Most payment acquirers will define specific +fields to store their credentials, so glue modules are required to include them +in `_server_env_fields` if that's what you want. + +Example of config file :: + + [payment_acquirer.paypal] + state = test diff --git a/payment_environment/readme/CONTRIBUTORS.rst b/payment_environment/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..902e23b04 --- /dev/null +++ b/payment_environment/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Camptocamp `_ + + * Iván Todorovich diff --git a/payment_environment/readme/DESCRIPTION.rst b/payment_environment/readme/DESCRIPTION.rst new file mode 100644 index 000000000..a95504ea1 --- /dev/null +++ b/payment_environment/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module allows to configure payment acquirers using server_environment files. diff --git a/payment_environment/readme/INSTALL.rst b/payment_environment/readme/INSTALL.rst new file mode 100644 index 000000000..416f78f29 --- /dev/null +++ b/payment_environment/readme/INSTALL.rst @@ -0,0 +1,5 @@ +To install this module, you need to have the server_environment module +installed and properly configured. + +After installed, the environment configurable fields will be read from +the environment files. diff --git a/payment_environment/readme/ROADMAP.rst b/payment_environment/readme/ROADMAP.rst new file mode 100644 index 000000000..89b97edfc --- /dev/null +++ b/payment_environment/readme/ROADMAP.rst @@ -0,0 +1 @@ +Due to the special nature of this addon, you cannot test it on the OCA runbot. diff --git a/payment_environment/readme/USAGE.rst b/payment_environment/readme/USAGE.rst new file mode 100644 index 000000000..87c3a7be4 --- /dev/null +++ b/payment_environment/readme/USAGE.rst @@ -0,0 +1,2 @@ +Once configured, Odoo will read the payment acquirer values from the +configuration file related to each environment defined in the main Odoo file. diff --git a/payment_environment/views/payment_acquirer.xml b/payment_environment/views/payment_acquirer.xml new file mode 100644 index 000000000..1f238ab75 --- /dev/null +++ b/payment_environment/views/payment_acquirer.xml @@ -0,0 +1,18 @@ + + + + + payment.acquirer + + + + + + + + + diff --git a/setup/payment_environment/odoo/addons/payment_environment b/setup/payment_environment/odoo/addons/payment_environment new file mode 120000 index 000000000..45015798e --- /dev/null +++ b/setup/payment_environment/odoo/addons/payment_environment @@ -0,0 +1 @@ +../../../../payment_environment \ No newline at end of file diff --git a/setup/payment_environment/setup.py b/setup/payment_environment/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/payment_environment/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)