[IMP] res_users,res_partner: login = email
bzr revid: chm@openerp.com-20130326130127-974jagzvhon0biiy
This commit is contained in:
parent
9b5db9ad9e
commit
0cf0cf4f4c
|
@ -193,6 +193,12 @@ class res_partner(osv.osv, format_address):
|
|||
result[obj.id] = obj.image != False
|
||||
return result
|
||||
|
||||
def _has_user_ids(self, cr, uid, ids, name, args, context=None):
|
||||
result = {}
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
result[obj.id] = bool(obj.user_ids)
|
||||
return result
|
||||
|
||||
_order = "name"
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True, select=True),
|
||||
|
@ -263,6 +269,7 @@ class res_partner(osv.osv, format_address):
|
|||
'company_id': fields.many2one('res.company', 'Company', select=1),
|
||||
'color': fields.integer('Color Index'),
|
||||
'user_ids': fields.one2many('res.users', 'partner_id', 'Users'),
|
||||
'has_user_ids': fields.function(_has_user_ids, type='boolean', string='Is a user'),
|
||||
'contact_address': fields.function(_address_display, type='char', string='Complete Address'),
|
||||
}
|
||||
|
||||
|
@ -359,10 +366,14 @@ class res_partner(osv.osv, format_address):
|
|||
# _constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])]
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if context is None:
|
||||
context={}
|
||||
# Update parent and siblings or children records
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
user_ids = []
|
||||
for partner in self.browse(cr, uid, ids, context=context):
|
||||
user_ids += [user.id for user in partner.user_ids]
|
||||
update_ids = []
|
||||
if partner.is_company:
|
||||
domain_children = [('parent_id', 'child_of', partner.id), ('use_parent_address', '=', True)]
|
||||
|
@ -371,6 +382,9 @@ 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):
|
||||
|
|
|
@ -111,7 +111,8 @@
|
|||
<group>
|
||||
<field name="category_id" widget="many2many_tags" placeholder="Tags..."/>
|
||||
<field name="function" placeholder="e.g. Sales Director"/>
|
||||
<field name="email" required="context.get('force_email', False)"/>
|
||||
<field name="has_user_ids" invisible="1"/>
|
||||
<field name="email" widget="email" required="context.get('force_email', False)" attrs="{'required': [('has_user_ids','!=', False)]}"/>
|
||||
<field name="phone"/>
|
||||
<field name="mobile"/>
|
||||
</group>
|
||||
|
@ -175,7 +176,8 @@
|
|||
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
||||
<field name="mobile"/>
|
||||
<field name="fax"/>
|
||||
<field name="email" widget="email"/>
|
||||
<field name="has_user_ids" invisible="1"/>
|
||||
<field name="email" widget="email" attrs="{'required': [('has_user_ids','!=', False)]}"/>
|
||||
<field name="title" domain="[('domain', '=', 'contact')]"
|
||||
options='{"no_open": True}' attrs="{'invisible': [('is_company','=', True)]}" />
|
||||
</group>
|
||||
|
@ -420,7 +422,7 @@
|
|||
<field name="view_id" ref="view_partner_tree"/>
|
||||
<field name="act_window_id" ref="action_partner_form"/>
|
||||
</record>
|
||||
<menuitem id="menu_partner_form" parent="base.menu_sales" action="action_partner_form" sequence="1"/>
|
||||
<menuitem id="menu_partner_form" parent="base.menu_sales" action="action_partner_form" sequence="2"/>
|
||||
|
||||
<record id="action_partner_customer_form" model="ir.actions.act_window">
|
||||
<field name="name">Customers</field>
|
||||
|
|
|
@ -278,6 +278,10 @@ 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_')):
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
<div class="oe_title">
|
||||
<label for="name" class="oe_edit_only"/>
|
||||
<h1><field name="name"/></h1>
|
||||
<label for="login" class="oe_edit_only"/>
|
||||
<label for="login" class="oe_edit_only" string="Email (= login)"/>
|
||||
<h2><field name="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"/>
|
||||
|
@ -152,14 +152,6 @@
|
|||
<field name="groups_id"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Contact">
|
||||
<group>
|
||||
<field name="phone" placeholder="e.g. +32.81.81.37.00"/>
|
||||
<field name="mobile"/>
|
||||
<field name="fax"/>
|
||||
<field name="email" widget="email"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Preferences">
|
||||
<group>
|
||||
<group name="preferences">
|
||||
|
@ -244,7 +236,6 @@
|
|||
<field name="image" widget='image' class="oe_right oe_avatar" options='{"preview_image": "image_small"}'/>
|
||||
<h1>
|
||||
<field name="name" readonly="1" class="oe_inline"/>
|
||||
(<field name="login" readonly="1" class="oe_inline"/>)
|
||||
</h1>
|
||||
<button name="preference_change_password" type="object" string="Change password" class="oe_link"/>
|
||||
<group name="preferences" col="4">
|
||||
|
|
Loading…
Reference in New Issue