[IMP] pseudo-merge of feature branch: email field in res.users (sorry for cherry-picking but the feature branch is not correctly rooted)
bzr revid: odo@openerp.com-20100521135457-kg5v25gs76kqne6f
This commit is contained in:
parent
83b59e43d6
commit
ab9b14ac03
|
@ -109,13 +109,13 @@
|
|||
<notebook colspan="4">
|
||||
<page string="User">
|
||||
<field name="address_id" select="1"/>
|
||||
<field name="user_email" widget="email"/>
|
||||
<field name="company_id" required="1"/>
|
||||
<field name="action_id" required="True"/>
|
||||
<field domain="[('usage','=','menu')]" name="menu_id" required="True"/>
|
||||
<field name="context_lang"/>
|
||||
<field name="context_tz"/>
|
||||
<field name="view" readonly="0" />
|
||||
<newline/>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Signature" colspan="2"/>
|
||||
<field colspan="2" name="signature" nolabel="1"/>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
from osv import fields,osv
|
||||
from osv.orm import except_orm, browse_record
|
||||
import tools
|
||||
import operator
|
||||
import pytz
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
|
@ -197,6 +198,21 @@ 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):
|
||||
return dict(map(operator.attrgetter('id', 'address_id.email'), self.browse(cr, uid, ids, context=context)))
|
||||
|
||||
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):
|
||||
if user.address_id:
|
||||
address_obj.write(cr, uid, user.address_id.id, {'email': value or None}, context=context)
|
||||
else:
|
||||
address_id = address_obj.create(cr, uid, {'name': user.name, 'email': value or None}, context=context)
|
||||
self.write(cr, uid, ids, {'address_id': address_id}, context)
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, required=True, select=True,
|
||||
help="The new user's real name, used for searching"
|
||||
|
@ -228,6 +244,7 @@ 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="Choose between the simplified interface and the extended one"),
|
||||
'user_email': fields.function(_email_get, method=True, fnct_inv=_email_set, string='Email', type="char"),
|
||||
}
|
||||
|
||||
def read(self,cr, uid, ids, fields=None, context=None, load='_classic_read'):
|
||||
|
|
Loading…
Reference in New Issue