Skip to content

Commit 326cc56

Browse files
committed
auth_admin_passkey to new API
1 parent e79f138 commit 326cc56

2 files changed

Lines changed: 38 additions & 61 deletions

File tree

auth_admin_passkey/model/res_config.py

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,51 @@
2020
#
2121
##############################################################################
2222

23-
from openerp.osv import fields
24-
from openerp.osv.orm import TransientModel
25-
from openerp.tools.safe_eval import safe_eval
23+
from openerp import api, fields, models
2624

2725

28-
class base_config_settings(TransientModel):
26+
class base_config_settings(models.TransientModel):
2927
_inherit = 'base.config.settings'
3028

3129
# Getter / Setter Section
32-
def get_default_auth_admin_passkey_send_to_admin(
33-
self, cr, uid, ids, context=None):
34-
icp = self.pool['ir.config_parameter']
30+
@api.model
31+
def get_default_auth_admin_passkey_send_to_admin(self, fields):
3532
return {
36-
'auth_admin_passkey_send_to_admin': safe_eval(icp.get_param(
37-
cr, uid, 'auth_admin_passkey.send_to_admin', 'True')),
33+
'auth_admin_passkey_send_to_admin':
34+
self.env["ir.config_parameter"].get_param(
35+
"auth_admin_passkey.send_to_admin")
3836
}
3937

40-
def set_auth_admin_passkey_send_to_admin(self, cr, uid, ids, context=None):
41-
config = self.browse(cr, uid, ids[0], context=context)
42-
icp = self.pool['ir.config_parameter']
43-
icp.set_param(
44-
cr, uid, 'auth_admin_passkey.send_to_admin',
45-
repr(config.auth_admin_passkey_send_to_admin))
38+
@api.multi
39+
def set_auth_admin_passkey_send_to_admin(self):
40+
for config in self:
41+
self.env['ir.config_parameter'].set_param(
42+
"auth_admin_passkey.send_to_admin",
43+
config.auth_admin_passkey_send_to_admin or '')
4644

47-
def get_default_auth_admin_passkey_send_to_user(
48-
self, cr, uid, ids, context=None):
49-
icp = self.pool['ir.config_parameter']
45+
@api.model
46+
def get_default_auth_admin_passkey_send_to_user(self, fields):
5047
return {
51-
'auth_admin_passkey_send_to_user': safe_eval(icp.get_param(
52-
cr, uid, 'auth_admin_passkey.send_to_user', 'True')),
48+
'auth_admin_passkey_send_to_user':
49+
self.env["ir.config_parameter"].get_param(
50+
"auth_admin_passkey.send_to_user")
5351
}
5452

55-
def set_auth_admin_passkey_send_to_user(self, cr, uid, ids, context=None):
56-
config = self.browse(cr, uid, ids[0], context=context)
57-
icp = self.pool['ir.config_parameter']
58-
icp.set_param(
59-
cr, uid, 'auth_admin_passkey.send_to_user',
60-
repr(config.auth_admin_passkey_send_to_user))
53+
@api.multi
54+
def set_auth_admin_passkey_send_to_user(self):
55+
for config in self:
56+
self.env['ir.config_parameter'].set_param(
57+
"auth_admin_passkey.send_to_user",
58+
config.auth_admin_passkey_send_to_user or '')
6159

62-
# Columns Section
63-
_columns = {
64-
'auth_admin_passkey_send_to_admin': fields.boolean(
65-
'Send email to admin user.',
66-
help="""When the administrator use his password to login in """
67-
"""with a different account, OpenERP will send an email """
68-
"""to the admin user.""",
69-
),
70-
'auth_admin_passkey_send_to_user': fields.boolean(
71-
string='Send email to user.',
72-
help="""When the administrator use his password to login in """
73-
"""with a different account, OpenERP will send an email """
74-
"""to the account user.""",
75-
),
76-
}
60+
auth_admin_passkey_send_to_admin = fields.Boolean(
61+
string='Send email to admin user.',
62+
help="""When the administrator use his password to login in """
63+
"""with a different account, OpenERP will send an email """
64+
"""to the admin user.""")
65+
66+
auth_admin_passkey_send_to_user = fields.Boolean(
67+
string='Send email to user.',
68+
help="""When the administrator use his password to login in """
69+
"""with a different account, OpenERP will send an email """
70+
"""to the account user.""")

auth_admin_passkey/model/res_users.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
# -*- encoding: utf-8 -*-
2-
##############################################################################
3-
#
4-
# Admin Passkey module for OpenERP
5-
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
6-
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
7-
#
8-
# This program is free software: you can redistribute it and/or modify
9-
# it under the terms of the GNU Affero General Public License as
10-
# published by the Free Software Foundation, either version 3 of the
11-
# License, or (at your option) any later version.
12-
#
13-
# This program is distributed in the hope that it will be useful,
14-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-
# GNU Affero General Public License for more details.
17-
#
18-
# You should have received a copy of the GNU Affero General Public License
19-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20-
#
21-
##############################################################################
2+
# Copyright (C) 2013-2014 GRAP (http://www.grap.coop)
3+
# @author Sylvain LE GAL (https://twitter.com/legalsylvain)
4+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
225

236
import datetime
247

0 commit comments

Comments
 (0)