[12.0][ADD] add base_iap_alternative
parent
0a3dda46e1
commit
da4947a10c
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright 2020 Akretion (https://www.akretion.com).
|
||||||
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
|
# 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": [],
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
from . import iap_account
|
|
@ -0,0 +1,42 @@
|
||||||
|
# Copyright 2020 Akretion (https://www.akretion.com).
|
||||||
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
|
# 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
|
|
@ -0,0 +1 @@
|
||||||
|
* Sébastien BEAU <sebastien.beau@akretion.com>
|
|
@ -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)
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="iap_account_view_form" model="ir.ui.view">
|
||||||
|
<field name="model">iap.account</field>
|
||||||
|
<field name="inherit_id" ref="iap.iap_account_view_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//group[@name='account']" position="before">
|
||||||
|
<group string="Info" name="info">
|
||||||
|
<field name="provider" />
|
||||||
|
<field name="name" />
|
||||||
|
</group>
|
||||||
|
</xpath>
|
||||||
|
<group name="account" position="attributes">
|
||||||
|
<attribute
|
||||||
|
name="attrs"
|
||||||
|
>{'invisible': [('provider', '!=', 'odoo')]}</attribute>
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue