Skip to content

Commit

Permalink
[ADD] payment_environment
Browse files Browse the repository at this point in the history
  • Loading branch information
ivantodorovich committed Aug 18, 2021
1 parent 314d16d commit eafa5f8
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions payment_environment/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions payment_environment/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Camptocamp SA
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# 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"],
}
1 change: 1 addition & 0 deletions payment_environment/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import payment_acquirer
19 changes: 19 additions & 0 deletions payment_environment/models/payment_acquirer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2021 Camptocamp SA
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from odoo import models


class PaymentAcquirer(models.Model):
_name = "payment.acquirer"
_inherit = ["payment.acquirer", "server.env.techname.mixin"]

@property
def _server_env_fields(self):
base_fields = super()._server_env_fields
acquirer_fields = {
"state": {},
}
acquirer_fields.update(base_fields)
return acquirer_fields
17 changes: 17 additions & 0 deletions payment_environment/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions payment_environment/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Camptocamp <https://www.camptocamp.com>`_

* Iván Todorovich <ivan.todorovich@gmail.com>
1 change: 1 addition & 0 deletions payment_environment/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows to configure payment acquirers using server_environment files.
5 changes: 5 additions & 0 deletions payment_environment/readme/INSTALL.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions payment_environment/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Due to the special nature of this addon, you cannot test it on the OCA runbot.
2 changes: 2 additions & 0 deletions payment_environment/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions payment_environment/views/payment_acquirer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2021 Camptocamp SA
@author Iván Todorovich <ivan.todorovich@gmail.com>
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
-->
<odoo>
<record id="acquirer_form" model="ir.ui.view">
<field name="model">payment.acquirer</field>
<field name="inherit_id" ref="payment.acquirer_form" />
<field name="groups_id" eval="[(4, ref('base.group_system'))]" />
<field name="arch" type="xml">
<field name="provider" position="before">
<field name="tech_name" groups="base.group_no_one" />
</field>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/payment_environment/odoo/addons/payment_environment
6 changes: 6 additions & 0 deletions setup/payment_environment/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit eafa5f8

Please sign in to comment.