From caa3c07094a5250b18c7cd44f7f4708b4e08907c Mon Sep 17 00:00:00 2001 From: "RavishchanraMurari (Open ERP)" Date: Thu, 28 Jul 2011 11:41:56 +0530 Subject: [PATCH] email.addresss_id_repalce_by_user_email bzr revid: rmu@tinyerp.com-20110728061156-swmn5jz78zb3w4vd --- addons/base_action_rule/base_action_rule.py | 16 +++++++--------- addons/base_calendar/base_calendar.py | 8 ++++---- .../wizard/base_calendar_invite_attendee.py | 6 +++--- addons/crm/crm.py | 12 ++++-------- addons/crm/crm_action_rule.py | 4 ++-- addons/mail_gateway/mail_gateway.py | 4 ++-- addons/project/project_view.xml | 1 - addons/project/wizard/project_task_close.py | 4 ++-- addons/project_mailgate/project_mailgate.py | 2 +- .../project_scrum/wizard/project_scrum_email.py | 2 +- addons/survey/survey.py | 2 +- 11 files changed, 27 insertions(+), 34 deletions(-) diff --git a/addons/base_action_rule/base_action_rule.py b/addons/base_action_rule/base_action_rule.py index 80c1ab464f1..7494cb37903 100644 --- a/addons/base_action_rule/base_action_rule.py +++ b/addons/base_action_rule/base_action_rule.py @@ -277,10 +277,8 @@ the rule to mark CC(mail to any other person defined in actions)."), 'object_date': hasattr(obj, 'date') and obj.date or False, 'object_description': hasattr(obj, 'description') and obj.description or False, 'object_user': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.name) or '/', - 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and \ - obj.user_id.address_id and obj.user_id.address_id.email) or '/', - 'object_user_phone': hasattr(obj, 'user_id') and (obj.user_id and\ - obj.user_id.address_id and obj.user_id.address_id.phone) or '/', + 'object_user_email': hasattr(obj, 'user_id') and (obj.user_id and obj.user_id.user_email) or '/', + 'object_user_phone': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and obj.partner_address_id.phone) or '/', 'partner': hasattr(obj, 'partner_id') and (obj.partner_id and obj.partner_id.name) or '/', 'partner_email': hasattr(obj, 'partner_address_id') and (obj.partner_address_id and\ obj.partner_address_id.email) or '/', @@ -304,9 +302,9 @@ the rule to mark CC(mail to any other person defined in actions)."), body = self.format_mail(obj, body) if not emailfrom: - if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and\ - obj.user_id.address_id.email: - emailfrom = obj.user_id.address_id.email + if hasattr(obj, 'user_id') and obj.user_id and\ + obj.user_id.user_email: + emailfrom = obj.user_id.user_email name = '[%d] %s' % (obj.id, tools.ustr(obj.name)) emailfrom = tools.ustr(emailfrom) @@ -404,8 +402,8 @@ the rule to mark CC(mail to any other person defined in actions)."), emails = [] if hasattr(obj, 'user_id') and action.act_mail_to_user: - if obj.user_id and obj.user_id.address_id: - emails.append(obj.user_id.address_id.email) + if obj.user_id: + emails.append(obj.user_id.user_email) if action.act_mail_to_watchers: emails += (action.act_email_cc or '').split(',') diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 5f24b08884a..a128e18fcc1 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -245,7 +245,7 @@ class calendar_attendee(osv.osv): continue else: result[id][name] = self._get_address(attdata.sent_by_uid.name, \ - attdata.sent_by_uid.address_id.email) + attdata.sent_by_uid.user_email) if name == 'cn': if attdata.user_id: @@ -535,7 +535,7 @@ property or property parameter."), return {'value': {'email': ''}} usr_obj = self.pool.get('res.users') user = usr_obj.browse(cr, uid, user_id, *args) - return {'value': {'email': user.address_id.email, 'availability':user.availability}} + return {'value': {'email': user.user_email, 'availability':user.availability}} def do_tentative(self, cr, uid, ids, context=None, *args): """ Makes event invitation as Tentative @@ -889,9 +889,9 @@ From: """ % (alarm.name, alarm.trigger_date, alarm.description, \ alarm.user_id.name, alarm.user_id.signature) - mail_to = [alarm.user_id.address_id.email] + mail_to = [alarm.user_id.user_email] for att in alarm.attendee_ids: - mail_to.append(att.user_id.address_id.email) + mail_to.append(att.user_id.user_email) if mail_to: tools.email_send( tools.config.get('email_from', False), diff --git a/addons/base_calendar/wizard/base_calendar_invite_attendee.py b/addons/base_calendar/wizard/base_calendar_invite_attendee.py index 7d5b26026b5..a429db8e925 100644 --- a/addons/base_calendar/wizard/base_calendar_invite_attendee.py +++ b/addons/base_calendar/wizard/base_calendar_invite_attendee.py @@ -98,12 +98,12 @@ send an Email to Invited Person') user = user_obj.browse(cr, uid, user_id) res = { 'user_id': user_id, - 'email': user.address_id.email + 'email': user.user_email } res.update(ref) vals.append(res) - if user.address_id.email: - mail_to.append(user.address_id.email) + if user.user_email: + mail_to.append(user.user_email) elif type == 'external' and datas.get('email'): res = {'email': datas['email']} diff --git a/addons/crm/crm.py b/addons/crm/crm.py index 0b1e8db7bbb..d64ef2ec97e 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -65,7 +65,7 @@ class crm_base(object): context = {} if not context.get('portal'): return False - return self.pool.get('res.users').browse(cr, uid, uid, context).address_id.id + return self.pool.get('res.partner.address').browse(cr, uid, uid, context) def _get_default_partner(self, cr, uid, context=None): """Gives id of partner for current user @@ -75,10 +75,8 @@ class crm_base(object): context = {} if not context.get('portal', False): return False - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if not user.address_id: - return False - return user.address_id.partner_id.id + part_id = self.pool.get('res.partner.address').browse(cr, uid, uid, context=context) + return part_id.partner_id def _get_default_email(self, cr, uid, context=None): """Gives default email address for current user @@ -87,9 +85,7 @@ class crm_base(object): if not context.get('portal', False): return False user = self.pool.get('res.users').browse(cr, uid, uid, context=context) - if not user.address_id: - return False - return user.address_id.email + return user.user_email def _get_default_user(self, cr, uid, context=None): """Gives current user id diff --git a/addons/crm/crm_action_rule.py b/addons/crm/crm_action_rule.py index 6eb3de3c35f..31dcc0be56a 100644 --- a/addons/crm/crm_action_rule.py +++ b/addons/crm/crm_action_rule.py @@ -48,8 +48,8 @@ this if you want the rule to send an email to the partner."), def email_send(self, cr, uid, obj, emails, body, emailfrom=tools.config.get('email_from', False), context=None): body = self.format_mail(obj, body) if not emailfrom: - if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.address_id and obj.user_id.address_id.email: - emailfrom = obj.user_id.address_id.email + if hasattr(obj, 'user_id') and obj.user_id and obj.user_id.user_email: + emailfrom = obj.user_id.user_email name = '[%d] %s' % (obj.id, tools.ustr(obj.name)) emailfrom = tools.ustr(emailfrom) diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index 4fa70484666..f4c45bf0ff8 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -164,8 +164,8 @@ class mailgate_thread(osv.osv): 'description': details or (hasattr(case, 'description') and case.description or False), 'email_to': email, 'email_from': email_from or \ - (hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \ - case.user_id.address_id.email), + (hasattr(case, 'user_id') and case.user_id and \ + case.user_id.user_email), 'email_cc': email_cc, 'email_bcc': email_bcc, 'partner_id': partner_id, diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 5cda5222e35..70eef194c2c 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -63,7 +63,6 @@ - diff --git a/addons/project/wizard/project_task_close.py b/addons/project/wizard/project_task_close.py index 010bba9e52b..627864820f6 100644 --- a/addons/project/wizard/project_task_close.py +++ b/addons/project/wizard/project_task_close.py @@ -84,8 +84,8 @@ class project_task_close(osv.osv_memory): elif data.manager_warn or data.partner_warn: project = task.project_id subject = _("Task '%s' Closed") % task.name - if task.user_id and task.user_id.address_id and task.user_id.address_id.email: - from_adr = task.user_id.address_id.email + if task.user_id and task.user_id.user_email: + from_adr = task.user_id.user_email signature = task.user_id.signature else: raise osv.except_osv(_('Error'), _("Couldn't send mail because your email address is not configured!")) diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index 66eaa2e85fa..2325d533c03 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -103,7 +103,7 @@ class project_tasks(osv.osv): else: select = ids for task in self.browse(cr, uid, select, context=context): - user_email = (task.user_id and task.user_id.address_id and task.user_id.address_id.email) or False + user_email = (task.user_id and task.user_id.user_email) or False res += [(user_email, False, False, task.priority)] if isinstance(ids, (str, int, long)): return len(res) and res[0] or False diff --git a/addons/project_scrum/wizard/project_scrum_email.py b/addons/project_scrum/wizard/project_scrum_email.py index ae8ba092981..f2e8dd79446 100644 --- a/addons/project_scrum/wizard/project_scrum_email.py +++ b/addons/project_scrum/wizard/project_scrum_email.py @@ -82,7 +82,7 @@ class project_scrum_email(osv.osv_memory): email_from = tools.config.get('email_from', False) user = user_pool.browse(cr, uid, uid, context=context) - user_email = email_from or user.address_id.email + user_email = email_from or user.user_email body = "%s\n" %(data.message) body += "\n%s\n" %_('Tasks since yesterday') diff --git a/addons/survey/survey.py b/addons/survey/survey.py index 74d15382670..bd27f313d82 100644 --- a/addons/survey/survey.py +++ b/addons/survey/survey.py @@ -741,7 +741,7 @@ class survey_request(osv.osv): if user_id: user_obj = self.pool.get('res.users') user = user_obj.browse(cr, uid, user_id, context=context) - return {'value': {'email': user.address_id.email}} + return {'value': {'email': user.user_email}} return {} survey_request()