From 7ae3f0b5c4aceddedf3ca679a8154c5b3a9f187f Mon Sep 17 00:00:00 2001 From: Mourad Elhadj Mimoune Date: Tue, 3 Oct 2017 15:47:43 +0200 Subject: [PATCH] [FIX] OCA reviews --- keychain/models/keychain_backend.py | 15 +++++++++++++-- keychain/tests/__init__.py | 2 +- keychain/tests/test_keychain_backend.py | 1 - keychain/views/keychain_view.xml | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/keychain/models/keychain_backend.py b/keychain/models/keychain_backend.py index 1e909a806..d4946930a 100644 --- a/keychain/models/keychain_backend.py +++ b/keychain/models/keychain_backend.py @@ -2,7 +2,7 @@ # © 2016 Akretion Sebastien Beau # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import api, fields, models from odoo.tools.config import config @@ -17,11 +17,15 @@ class KeychainBackend(models.AbstractModel): required=True) data = fields.Serialized( compute="_compute_keychain", - inverse="_inverse_keychain") + inverse="_inverse_keychain", + help="Additionnal data as json") + @api.multi def _get_technical_name(self): + self.ensure_one() return '%s,%s' % (self._name, self.id) + @api.multi def _get_existing_keychain(self): self.ensure_one() return self.env['keychain.account'].retrieve([ @@ -29,7 +33,9 @@ class KeychainBackend(models.AbstractModel): ('technical_name', '=', self._get_technical_name()) ]) + @api.multi def _prepare_keychain(self): + self.ensure_one() env = config.get('running_env') return { 'name': "%s %s" % (self.name, env), @@ -38,6 +44,7 @@ class KeychainBackend(models.AbstractModel): 'environment': env, } + @api.multi def _get_keychain_account(self): self.ensure_one() account = self._get_existing_keychain() @@ -46,12 +53,14 @@ class KeychainBackend(models.AbstractModel): account = self.env['keychain.account'].create(vals) return account + @api.multi def _inverse_password(self): for record in self: account = self._get_keychain_account() if record.password and record.password != '******': account.clear_password = record.password + @api.multi def _compute_password(self): for record in self: account = record._get_existing_keychain() @@ -60,11 +69,13 @@ class KeychainBackend(models.AbstractModel): else: record.password = "" + @api.multi def _inverse_keychain(self): for record in self: account = record._get_keychain_account() account.data = account._serialize_data(record.data) + @api.multi def _compute_keychain(self): for record in self: account = record._get_existing_keychain() diff --git a/keychain/tests/__init__.py b/keychain/tests/__init__.py index 5ac20c916..45fd45d97 100644 --- a/keychain/tests/__init__.py +++ b/keychain/tests/__init__.py @@ -1,2 +1,2 @@ from . import test_keychain -from . import test_keychain_backend \ No newline at end of file +from . import test_keychain_backend diff --git a/keychain/tests/test_keychain_backend.py b/keychain/tests/test_keychain_backend.py index f20b796f7..4b38b7108 100644 --- a/keychain/tests/test_keychain_backend.py +++ b/keychain/tests/test_keychain_backend.py @@ -79,4 +79,3 @@ class TestKeychain(TransactionCase): self.assertEqual( account.technical_name, '%s,%s' % (backend._name, backend.id), 'Account technical_name is not correct') - diff --git a/keychain/views/keychain_view.xml b/keychain/views/keychain_view.xml index 6dc746e2a..c5b8003e3 100644 --- a/keychain/views/keychain_view.xml +++ b/keychain/views/keychain_view.xml @@ -4,7 +4,7 @@ keychain.account - + @@ -18,7 +18,7 @@ keychain.account -
+