Merge lp:~openerp-dev/openerp-web/7.0-opw-590098-msh into lp:openerp-web/7.0

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/7.0-opw-590098-msh
Merge into: lp:openerp-web/7.0
Diff against target: 37 lines (+11/-6)
1 file modified
addons/web_calendar/static/src/js/calendar.js (+11/-6)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-opw-590098-msh
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) Pending
Xavier (Open ERP) Pending
OpenERP Core Team Pending
Review via email: mp+155236@code.launchpad.net

Description of the change

Hello,

Fixed the issue of calendar which shows wrong time whne calendar view is developed on date type field.

Demo:- Go to Project Task -> Taks calendar view see the time on month mode or create new calendar event and see time, it always give 9:00+/- your timezone difference from UTC, say for example I am in timezone UTC_5:30 so event is always created in 14:30.

Reason:- It is because calendar view is implmeneted in field type date, logically there is no meaning to use date type field on calendar view because calendar view shows Day and Week mode which shows meeting on time values, so calendar view should be implemented on datetime field but even if develper implemented on date field so we have handled that scenario also, calendar creates meeting from 9:00 to 17:00 for field type date, but the only issue after this is after adding 9:00 and 17:00 hours to date_Start and date_deadline it convertes that date in to local timezone so UTC+5:30 converted to 14:30, which is abnormal behaviour, I have one scenario where this thing make major issue.
If I am in timezone UTC+11(say for example region of USA Samoa), now I create event so 9:00 - 11:00 hours that is 22:00 PM of previous day, so event is created with 22:00 to 6:00 AM of next day(8:00 hour's event) so event is created for 2 days which is wrong.

The behavior should be same for any timezone, event should be displayed on 9:00 AM on any timezone when it is based on date field.

This branch will fix the issue of timezone but it is wise to implement calendar view on datetime field.

Thanks.

To post a comment you must log in.

Unmerged revisions

3868. By Mohammed Shekha<email address hidden>

[FIX]Fixed the issue of calendar which shows wrong time whne calendar view is developed on date type field.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web_calendar/static/src/js/calendar.js'
2--- addons/web_calendar/static/src/js/calendar.js 2013-03-21 22:54:02 +0000
3+++ addons/web_calendar/static/src/js/calendar.js 2013-03-25 14:18:21 +0000
4@@ -294,10 +294,10 @@
5 }
6
7 if (this.fields[this.date_start]['type'] == 'date') {
8- evt[this.date_start] = instance.web.auto_str_to_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');
9+ evt[this.date_start] = instance.web.auto_str_to_date(evt[this.date_start]).toString('yyyy-MM-dd HH:mm:ss');
10 }
11 if (this.date_stop && evt[this.date_stop] && this.fields[this.date_stop]['type'] == 'date') {
12- evt[this.date_stop] = instance.web.auto_str_to_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');
13+ evt[this.date_stop] = instance.web.auto_str_to_date(evt[this.date_stop]).toString('yyyy-MM-dd HH:mm:ss');
14 }
15 res_events.push(this.convert_event(evt));
16 }
17@@ -308,11 +308,16 @@
18 }
19 },
20 convert_event: function(evt) {
21- var date_start = instance.web.str_to_datetime(evt[this.date_start]),
22+ var date_start = null, date_stop = null, date_delay = 1.0, res_text = '';
23+ if (this.fields[this.date_start]['type'] == 'date') {
24+ date_start = instance.web.str_to_datetime(evt[this.date_start]).set({hour: 9}).set({minute: 0}),
25+ date_stop = this.date_stop ? instance.web.str_to_datetime(evt[this.date_stop]).set({hour: 17}).set({minute: 0}) : null,
26+ date_delay = evt[this.date_delay] || 1.0
27+ }else {
28+ date_start = instance.web.str_to_datetime(evt[this.date_start]),
29 date_stop = this.date_stop ? instance.web.str_to_datetime(evt[this.date_stop]) : null,
30- date_delay = evt[this.date_delay] || 1.0,
31- res_text = '';
32-
33+ date_delay = evt[this.date_delay] || 1.0
34+ }
35 if (this.info_fields) {
36 res_text = _.map(this.info_fields, function(fld) {
37 if(evt[fld] instanceof Array)