- _order = 'name'
-
- WELCOME_MAIL_SUBJECT = u"Welcome to OpenERP"
- WELCOME_MAIL_BODY = u"An OpenERP account has been created for you, "\
- "\"%(name)s\".\n\nYour login is %(login)s, "\
- "you should ask your supervisor or system administrator if you "\
- "haven't been given your password yet.\n\n"\
- "If you aren't %(name)s, this email reached you errorneously, "\
- "please delete it."
-
- def get_welcome_mail_subject(self, cr, uid, context=None):
- """ Returns the subject of the mail new users receive (when
- created via the res.config.users wizard), default implementation
- is to return config_users.WELCOME_MAIL_SUBJECT
- """
- return self.WELCOME_MAIL_SUBJECT
- def get_welcome_mail_body(self, cr, uid, context=None):
- """ Returns the subject of the mail new users receive (when
- created via the res.config.users wizard), default implementation
- is to return config_users.WELCOME_MAIL_BODY
- """
- return self.WELCOME_MAIL_BODY
-
- def get_current_company(self, cr, uid):
- cr.execute('select company_id, res_company.name from res_users left join res_company on res_company.id = company_id where res_users.id=%s' %uid)
- return cr.fetchall()
-
- def send_welcome_email(self, cr, uid, id, context=None):
- if isinstance(id,list): id = id[0]
- user = self.read(cr, uid, id, ['email','login','name', 'user_email'], context=context)
- email = user['email'] or user['user_email']
-
- ir_mail_server = self.pool.get('ir.mail_server')
- msg = ir_mail_server.build_email(email_from=None, # take config default
- email_to=[email],
- subject=self.get_welcome_mail_subject(cr, uid, context=context),
- body=(self.get_welcome_mail_body(cr, uid, context=context) % user))
- return ir_mail_server.send_email(cr, uid, msg, context=context)
-
- def _set_interface_type(self, cr, uid, ids, name, value, arg, context=None):
- """Implementation of 'view' function field setter, sets the type of interface of the users.
- @param name: Name of the field
- @param arg: User defined argument
- @param value: new value returned
- @return: True/False
- """
- if not value or value not in ['simple','extended']:
- return False
- group_obj = self.pool.get('res.groups')
- extended_group_id = group_obj.get_extended_interface_group(cr, uid, context=context)
- # First always remove the users from the group (avoids duplication if called twice)
- self.write(cr, uid, ids, {'groups_id': [(3, extended_group_id)]}, context=context)
- # Then add them back if requested
- if value == 'extended':
- self.write(cr, uid, ids, {'groups_id': [(4, extended_group_id)]}, context=context)
- return True
-
-
- def _get_interface_type(self, cr, uid, ids, name, args, context=None):
- """Implementation of 'view' function field getter, returns the type of interface of the users.
- @param field_name: Name of the field
- @param arg: User defined argument
- @return: Dictionary of values
- """
- group_obj = self.pool.get('res.groups')
- extended_group_id = group_obj.get_extended_interface_group(cr, uid, context=context)
- 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]))