From f96f20e4d3f8354176504e420e01a37ebd1035b1 Mon Sep 17 00:00:00 2001 From: Chris Biersbach Date: Fri, 28 Dec 2012 09:45:27 +0100 Subject: [PATCH 1/3] [FIX] The default stage for issues and tasks is now correctly a draft stage of the project the issue or task belongs to. bzr revid: cbi@openerp.com-20121228084527-ive0ope41di6bpjn --- addons/project/project.py | 4 ++++ addons/project_issue/project_issue.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/addons/project/project.py b/addons/project/project.py index 0534ad9a264..a0acb2ac793 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1089,6 +1089,10 @@ class task(base_stage, osv.osv): return True def create(self, cr, uid, vals, context=None): + if not context.get('default_project_id', False) and vals.get('project_id', False): + ctx = context.copy() + ctx['default_project_id'] = vals['project_id'] + vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) return task_id diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index fcc6b3d0265..f4d8e828945 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -64,6 +64,13 @@ class project_issue(base_stage, osv.osv): }, } + def create(self, cr, uid, vals, context=None): + if not context.get('default_project_id', False) and vals.get('project_id', False): + ctx = context.copy() + ctx['default_project_id'] = vals['project_id'] + vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) + return super(project_issue, self).create(cr, uid, vals, context=context) + def _get_default_project_id(self, cr, uid, context=None): """ Gives default project by checking if present in the context """ return self._resolve_project_id_from_context(cr, uid, context=context) From 1cc8d504ab7ed272389de509433b3e011997b610 Mon Sep 17 00:00:00 2001 From: Arnaud Pineux Date: Fri, 28 Dec 2012 09:48:40 +0100 Subject: [PATCH 2/3] [FIX] base_calendar: remove followers & change the mail_to format in str to match with mail.mail bzr revid: api@openerp.com-20121228084840-a1ii9os6dn2xcw0q --- addons/base_calendar/base_calendar.py | 10 +++++----- addons/base_calendar/crm_meeting_view.xml | 4 ---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 297fc68be58..718521c8b08 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -842,7 +842,7 @@ class calendar_alarm(osv.osv): current_datetime = datetime.now() alarm_ids = self.search(cr, uid, [('state', '!=', 'done')], context=context) - mail_to = [] + mail_to = "" for alarm in self.browse(cr, uid, alarm_ids, context=context): next_trigger_date = None @@ -891,9 +891,9 @@ From: """ % (alarm.name, alarm.trigger_date, alarm.description, \ alarm.user_id.name, alarm.user_id.signature) - mail_to = [alarm.user_id.email] + mail_to = alarm.user_id.email for att in alarm.attendee_ids: - mail_to.append(att.user_id.email) + mail_to = mail_to+" "+att.user_id.email if mail_to: vals = { 'state': 'outgoing', @@ -1117,7 +1117,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), for att in event.attendee_ids: attendees[att.partner_id.id] = True new_attendees = [] - mail_to = [] + mail_to = "" for partner in event.partner_ids: if partner.id in attendees: continue @@ -1128,7 +1128,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), 'email': partner.email }, context=context) if partner.email: - mail_to.append(partner.email) + mail_to = mail_to+" "+partner.email self.write(cr, uid, [event.id], { 'attendee_ids': [(4, att_id)] }, context=context) diff --git a/addons/base_calendar/crm_meeting_view.xml b/addons/base_calendar/crm_meeting_view.xml index 2efc76997cc..c2adc01cd54 100644 --- a/addons/base_calendar/crm_meeting_view.xml +++ b/addons/base_calendar/crm_meeting_view.xml @@ -181,10 +181,6 @@ -
- - -
From e4b6282112fc80224ae5f626736703750d2686e7 Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Fri, 28 Dec 2012 10:42:36 +0100 Subject: [PATCH 3/3] [FIX] base_calendar: fixed the mail and ics file sent when inviting attendees to a meeting in order to format the dates and times in a correct timezone wich is now explicitly named bzr revid: qdp-launchpad@openerp.com-20121228094236-p1s8fdvhsothygkk --- addons/base_calendar/base_calendar.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 297fc68be58..d09b5684edb 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -142,7 +142,7 @@ html_invitation = """ You are invited for %(company)s Event. - Below are the details of event: + Below are the details of event. Hours and dates expressed in %(timezone)s time. @@ -427,12 +427,9 @@ property or property parameter."), res = None def ics_datetime(idate, short=False): if idate: - if short or len(idate)<=10: - return date.fromtimestamp(time.mktime(time.strptime(idate, '%Y-%m-%d'))) - else: - return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S') - else: - return False + #returns the datetime as UTC, because it is stored as it in the database + return datetime.strptime(idate, '%Y-%m-%d %H:%M:%S').replace(tzinfo=pytz.timezone('UTC')) + return False try: # FIXME: why isn't this in CalDAV? import vobject @@ -516,9 +513,17 @@ property or property parameter."), att_infos.append(((att2.user_id and att2.user_id.name) or \ (att2.partner_id and att2.partner_id.name) or \ att2.email) + ' - Status: ' + att2.state.title()) + #dates and times are gonna be expressed in `tz` time (local timezone of the `uid`) + tz = context.get('tz', pytz.timezone('UTC')) + #res_obj.date and res_obj.date_deadline are in UTC in database so we use context_timestamp() to transform them in the `tz` timezone + date_start = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) + date_stop = False + if res_obj.date_deadline: + date_stop = fields.datetime.context_timestamp(cr, uid, datetime.strptime(res_obj.date_deadline, tools.DEFAULT_SERVER_DATETIME_FORMAT), context=context) body_vals = {'name': res_obj.name, - 'start_date': res_obj.date, - 'end_date': res_obj.date_deadline or False, + 'start_date': date_start, + 'end_date': date_stop, + 'timezone': tz, 'description': res_obj.description or '-', 'location': res_obj.location or '-', 'attendees': '
'.join(att_infos), @@ -623,7 +628,7 @@ property or property parameter."), email = filter(lambda x:x.__contains__('@'), cnval) vals['email'] = email and email[0] or '' vals['cn'] = vals.get("cn") - res = super(calendar_attendee, self).create(cr, uid, vals, context) + res = super(calendar_attendee, self).create(cr, uid, vals, context=context) return res calendar_attendee() @@ -1136,7 +1141,7 @@ rule or repeating pattern of time to exclude from the recurring rule."), if mail_to and current_user.email: att_obj._send_mail(cr, uid, new_attendees, mail_to, - email_from = current_user.email) + email_from = current_user.email, context=context) return True def default_organizer(self, cr, uid, context=None):