Browse Source

Merge PR #1861 into 12.0

Signed-off-by sebastienbeau
12.0-mig-module_prototyper_last
OCA-git-bot 4 years ago
parent
commit
8368d794fc
  1. 1
      .travis.yml
  2. 1
      iap_alternative_provider/__init__.py
  3. 22
      iap_alternative_provider/__manifest__.py
  4. 1
      iap_alternative_provider/models/__init__.py
  5. 42
      iap_alternative_provider/models/iap_account.py
  6. 1
      iap_alternative_provider/readme/CONTRIBUTORS.rst
  7. 3
      iap_alternative_provider/readme/DESCRIPTION.rst
  8. 20
      iap_alternative_provider/views/iap_account_view.xml

1
.travis.yml

@ -25,7 +25,6 @@ env:
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="database_cleanup" MAKEPOT="1"
- TESTS="1" ODOO_REPO="odoo/odoo" INCLUDE="module_analysis" MAKEPOT="1"
install:
- git clone --depth=1 https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}

1
iap_alternative_provider/__init__.py

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

22
iap_alternative_provider/__manifest__.py

@ -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": [],
}

1
iap_alternative_provider/models/__init__.py

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

42
iap_alternative_provider/models/iap_account.py

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

1
iap_alternative_provider/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Sébastien BEAU <sebastien.beau@akretion.com>

3
iap_alternative_provider/readme/DESCRIPTION.rst

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

20
iap_alternative_provider/views/iap_account_view.xml

@ -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…
Cancel
Save