[MERGE] remove address_id from res_users

bzr revid: rco@openerp.com-20110803122335-boleg96hc1v3zzbi
This commit is contained in:
Raphael Collet 2011-08-03 14:23:35 +02:00
commit cf8204dc88
4 changed files with 35 additions and 31 deletions

View File

@ -23,7 +23,7 @@
{
'name': 'Base',
'version': '1.3',
'version': '1.4',
'category': 'Generic Modules/Base',
'complexity': "easy",
'description': """The kernel of OpenERP, needed for all installation.""",

View File

@ -134,7 +134,6 @@
<field name="user_email" widget="email"/>
</group>
<field colspan="4" name="signature" nolabel="1"/>
<newline/>
</page>
<page string="Access Rights">
<field nolabel="1" name="groups_id"/>
@ -168,7 +167,6 @@
<search string="Users">
<field name="name"/>
<field name="login"/>
<field name="address_id" string="Address"/>
<field name="company_ids" string="Company" groups="base.group_multi_company"/>
</search>
</field>

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
def migrate(cr, version):
""" copy emails from user.address_id.email to user.user_email, then drop
the column address_id
"""
cr.execute("""
UPDATE res_users
SET user_email = res_partner_address.email
FROM res_partner_address
WHERE res_users.address_id = res_partner_address.id""")
cr.execute("""
ALTER TABLE res_users DROP COLUMN address_id""")

View File

@ -193,25 +193,6 @@ class users(osv.osv):
extended_users = group_obj.read(cr, uid, extended_group_id, ['users'], context=context)['users']
return dict(zip(ids, ['extended' if user in extended_users else 'simple' for user in ids]))
def _email_get(self, cr, uid, ids, name, arg, context=None):
# perform this as superuser because the current user is allowed to read users, and that includes
# the email, even without any direct read access on the res_partner_address object.
return dict([(user.id, user.address_id.email) for user in self.browse(cr, 1, ids)]) # no context to avoid potential security issues as superuser
def _email_set(self, cr, uid, ids, name, value, arg, context=None):
if not isinstance(ids,list):
ids = [ids]
address_obj = self.pool.get('res.partner.address')
for user in self.browse(cr, uid, ids, context=context):
# perform this as superuser because the current user is allowed to write to the user, and that includes
# the email even without any direct write access on the res_partner_address object.
if user.address_id:
address_obj.write(cr, 1, user.address_id.id, {'email': value or None}) # no context to avoid potential security issues as superuser
else:
address_id = address_obj.create(cr, 1, {'name': user.name, 'email': value or None}) # no context to avoid potential security issues as superuser
self.write(cr, uid, ids, {'address_id': address_id}, context)
return True
def _set_new_password(self, cr, uid, id, name, value, args, context=None):
if value is False:
# Do not update the password if no value is provided, ignore silently.
@ -238,13 +219,8 @@ class users(osv.osv):
fnct_inv=_set_new_password,
string='Change password', help="Only specify a value if you want to change the user password. "
"This user will have to logout and login again!"),
'email': fields.char('E-mail', size=64,
help='If an email is provided, the user will be sent a message '
'welcoming him.\n\nWarning: if "email_from" and "smtp_server"'
" aren't configured, it won't be possible to email new "
"users."),
'user_email': fields.char('E-mail', size=64),
'signature': fields.text('Signature', size=64),
'address_id': fields.many2one('res.partner.address', 'Address'),
'active': fields.boolean('Active'),
'action_id': fields.many2one('ir.actions.actions', 'Home Action', help="If specified, this action will be opened at logon for this user, in addition to the standard menu."),
'menu_id': fields.many2one('ir.actions.actions', 'Menu Action', help="If specified, the action will replace the standard menu for this user."),
@ -265,7 +241,6 @@ class users(osv.osv):
'view': fields.function(_get_interface_type, method=True, type='selection', fnct_inv=_set_interface_type,
selection=[('simple','Simplified'),('extended','Extended')],
string='Interface', help="OpenERP offers a simplified and an extended user interface. If you use OpenERP for the first time we strongly advise you to select the simplified interface, which has less features but is easier to use. You can switch to the other interface from the User/Preferences menu at any time."),
'user_email': fields.function(_email_get, method=True, fnct_inv=_email_set, string='Email', type="char", size=240),
'menu_tips': fields.boolean('Menu Tips', help="Check out this box if you want to always display tips on each menu action"),
'date': fields.datetime('Last Connection', readonly=True),
}
@ -364,7 +339,6 @@ class users(osv.osv):
'company_id': _get_company,
'company_ids': _get_companies,
'groups_id': _get_group,
'address_id': False,
'menu_tips':True
}
@ -432,7 +406,6 @@ class users(osv.osv):
copy_pattern = _("%s (copy)")
copydef = dict(login=(copy_pattern % user2copy['login']),
name=(copy_pattern % user2copy['name']),
address_id=False, # avoid sharing the address of the copied user!
)
copydef.update(default)
return super(users, self).copy(cr, uid, id, copydef, context)