[ADD] payment_environment

This commit is contained in:
Ivàn Todorovich 2021-07-05 12:44:39 -03:00
parent 314d16d37c
commit 0ebfa8471f
13 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1 @@
from . import models

View File

@ -0,0 +1,16 @@
# Copyright 2021 Camptocamp SA
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
{
"name": "Payment Acquirers' configuration with server_environment",
"summary": "Configure payment acquirers with server_environment",
"category": "Tools",
"version": "13.0.1.0.0",
"license": "LGPL-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"],
}

View File

@ -0,0 +1 @@
from . import payment_acquirer

View File

@ -0,0 +1,23 @@
# Copyright 2021 Camptocamp SA
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# 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

View File

@ -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

View File

@ -0,0 +1,3 @@
* `Camptocamp <https://www.camptocamp.com>`_
* Iván Todorovich <ivan.todorovich@gmail.com>

View File

@ -0,0 +1 @@
This module allows to configure payment acquirers using server_environment files.

View File

@ -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.

View File

@ -0,0 +1 @@
Due to the special nature of this addon, you cannot test it on the OCA runbot.

View File

@ -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.

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2021 Camptocamp SA
@author Iván Todorovich <ivan.todorovich@gmail.com>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.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>

View File

@ -0,0 +1 @@
../../../../payment_environment

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)