[IMP] res_user: on change login, change email
bzr revid: chm@openerp.com-20130327132142-xth9hpxtfh3qa3or
This commit is contained in:
parent
d6f6e3ec4a
commit
0fc5753a43
|
@ -382,9 +382,6 @@ class res_partner(osv.osv, format_address):
|
|||
domain_siblings = [('parent_id', '=', partner.parent_id.id), ('use_parent_address', '=', True)]
|
||||
update_ids = [partner.parent_id.id] + self.search(cr, uid, domain_siblings, context=context)
|
||||
self.update_address(cr, uid, update_ids, vals, context)
|
||||
if vals.get('email') and user_ids and not context.get('change_email_and_login'):
|
||||
context.update({'change_email_and_login': True})
|
||||
self.pool.get('res.users').write(cr, uid, user_ids, {'login': vals.get('email')}, context=context)
|
||||
return super(res_partner,self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
|
|
@ -165,6 +165,9 @@ class res_users(osv.osv):
|
|||
deprecated='Use the email field instead of user_email. This field will be removed with OpenERP 7.1.'),
|
||||
}
|
||||
|
||||
def on_change_login(self, cr, uid, ids, login, context=None):
|
||||
return {'value': {'email': login}}
|
||||
|
||||
def on_change_company_id(self, cr, uid, ids, company_id):
|
||||
return {'warning' : {
|
||||
'title': _("Company Switch Warning"),
|
||||
|
@ -284,10 +287,6 @@ class res_users(osv.osv):
|
|||
def write(self, cr, uid, ids, values, context=None):
|
||||
if not hasattr(ids, '__iter__'):
|
||||
ids = [ids]
|
||||
if values.get('email'):
|
||||
values['login'] = values.get('email')
|
||||
if values.get('login'):
|
||||
values['email'] = values.get('login')
|
||||
if ids == [uid]:
|
||||
for key in values.keys():
|
||||
if not (key in self.SELF_WRITEABLE_FIELDS or key.startswith('context_')):
|
||||
|
|
|
@ -100,8 +100,9 @@
|
|||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
<label for="login" class="oe_edit_only"/>
|
||||
<h2><field name="login"/></h2>
|
||||
<field name="email" invisible="1"/>
|
||||
<label for="login" class="oe_edit_only" on_change="on_change_login(login)"/>
|
||||
<h2><field name="login" string="Login (Email)"/></h2>
|
||||
<label for="company_id" class="oe_edit_only" groups="base.group_multi_company"/>
|
||||
<field name="company_id" context="{'user_preference': 0}" groups="base.group_multi_company"/>
|
||||
</div>
|
||||
|
@ -114,7 +115,6 @@
|
|||
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
||||
<field name="mobile"/>
|
||||
<field name="fax"/>
|
||||
<field name="email" widget="email" required="True"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
@ -135,8 +135,9 @@
|
|||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
<label for="login" class="oe_edit_only" string="Email (= login)"/>
|
||||
<h2><field name="login"/></h2>
|
||||
<field name="email" invisible="1"/>
|
||||
<label for="login" class="oe_edit_only" string="Login (Email)"/>
|
||||
<h2><field name="login" on_change="on_change_login(login)"/></h2>
|
||||
<label for="company_id" class="oe_edit_only" groups="base.group_multi_company"/>
|
||||
<field name="company_id" context="{'user_preference': 0}" groups="base.group_multi_company"/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue