From 841accd1793c1e092ebbd02f13a4885e988a4158 Mon Sep 17 00:00:00 2001 From: Vidhin Mehta Date: Thu, 23 May 2013 17:35:17 +0530 Subject: [PATCH 1/9] [IMP]Introduce float_time concept in Timesheet Widget. bzr revid: vme@tinyerp.com-20130523120517-y281pkgqj66atthr --- .../static/src/js/timesheet.js | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index fe7d0c82767..9a272051655 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -163,24 +163,41 @@ openerp.hr_timesheet_sheet = function(instance) { this.dfm = undefined; } }, + is_valid_value:function(value){ + var split_value = value.split(":"); + var wrong_value = true; + if (split_value.length > 2)return false; + _.detect(split_value,function(num){ + if(isNaN(num)){ + wrong_value = false; + } + }) + return wrong_value; + }, display_data: function() { var self = this; self.$el.html(QWeb.render("hr_timesheet_sheet.WeeklyTimesheet", {widget: self})); _.each(self.accounts, function(account) { _.each(_.range(account.days.length), function(day_count) { if (!self.get('effective_readonly')) { - self.get_box(account, day_count).val(self.sum_box(account, day_count)).change(function() { - var num = Number($(this).val()); + self.get_box(account, day_count).val(self.sum_box(account, day_count, true)).change(function() { + var num = $(this).val(); + if (self.is_valid_value(num)){ + num = Number(self.parse_client(num)); + } if (isNaN(num)) { - $(this).val(self.sum_box(account, day_count)); + $(this).val(self.sum_box(account, day_count, true)); } else { account.days[day_count].lines[0].unit_amount += num - self.sum_box(account, day_count); self.display_totals(); self.sync(); + if(!isNaN($(this).val())){ + $(this).val(self.sum_box(account, day_count, true)); + } } }); } else { - self.get_box(account, day_count).html(self.sum_box(account, day_count)); + self.get_box(account, day_count).html(self.sum_box(account, day_count, true)); } }); }); @@ -247,12 +264,12 @@ openerp.hr_timesheet_sheet = function(instance) { get_super_total: function() { return this.$('.oe_timesheet_weekly_supertotal'); }, - sum_box: function(account, day_count) { + sum_box: function(account, day_count, setter) { var line_total = 0; _.each(account.days[day_count].lines, function(line) { line_total += line.unit_amount; }); - return line_total; + return (setter)?this.format_client(line_total):line_total; }, display_totals: function() { var self = this; @@ -266,12 +283,12 @@ openerp.hr_timesheet_sheet = function(instance) { day_tots[day_count] += sum; super_tot += sum; }); - self.get_total(account).html(acc_tot); + self.get_total(account).html(self.format_client(acc_tot)); }); _.each(_.range(self.dates.length), function(day_count) { - self.get_day_total(day_count).html(day_tots[day_count]); + self.get_day_total(day_count).html(self.format_client(day_tots[day_count])); }); - self.get_super_total().html(super_tot); + self.get_super_total().html(self.format_client(super_tot)); }, sync: function() { var self = this; @@ -279,6 +296,14 @@ openerp.hr_timesheet_sheet = function(instance) { self.set({sheets: this.generate_o2m_value()}); self.setting = false; }, + //converts hour value to float + parse_client: function(value) { + return instance.web.parse_value(value, { type:"float_time" }); + }, + //converts float value to hour + format_client:function(value){ + return instance.web.format_value(value, { type:"float_time" }); + }, generate_o2m_value: function() { var self = this; var ops = []; From 41fd5d657da5d3d0a6d7e9dda851ec08d1a42d2c Mon Sep 17 00:00:00 2001 From: Vidhin Mehta Date: Thu, 23 May 2013 18:11:17 +0530 Subject: [PATCH 2/9] [IMP]Change Variable name. bzr revid: vme@tinyerp.com-20130523124117-g6hnj394fndmookq --- addons/hr_timesheet_sheet/static/src/js/timesheet.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index 9a272051655..90ce8eff39b 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -165,14 +165,14 @@ openerp.hr_timesheet_sheet = function(instance) { }, is_valid_value:function(value){ var split_value = value.split(":"); - var wrong_value = true; + var valid_value = true; if (split_value.length > 2)return false; _.detect(split_value,function(num){ if(isNaN(num)){ - wrong_value = false; + valid_value = false; } }) - return wrong_value; + return valid_value; }, display_data: function() { var self = this; @@ -264,12 +264,12 @@ openerp.hr_timesheet_sheet = function(instance) { get_super_total: function() { return this.$('.oe_timesheet_weekly_supertotal'); }, - sum_box: function(account, day_count, setter) { + sum_box: function(account, day_count, show_value_in_hour) { var line_total = 0; _.each(account.days[day_count].lines, function(line) { line_total += line.unit_amount; }); - return (setter)?this.format_client(line_total):line_total; + return (show_value_in_hour)?this.format_client(line_total):line_total; }, display_totals: function() { var self = this; From fcff0fcbea15f1db6eebae81660ec0ca8d2850c0 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 24 May 2013 10:55:34 +0200 Subject: [PATCH 3/9] [IMP] don't format 0 values bzr revid: mat@openerp.com-20130524085534-coh7tjadajiu4bv3 --- .../hr_timesheet_sheet/static/src/js/timesheet.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index 90ce8eff39b..e7d13c425b6 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -166,12 +166,13 @@ openerp.hr_timesheet_sheet = function(instance) { is_valid_value:function(value){ var split_value = value.split(":"); var valid_value = true; - if (split_value.length > 2)return false; + if (split_value.length > 2) + return false; _.detect(split_value,function(num){ if(isNaN(num)){ valid_value = false; } - }) + }); return valid_value; }, display_data: function() { @@ -183,15 +184,15 @@ openerp.hr_timesheet_sheet = function(instance) { self.get_box(account, day_count).val(self.sum_box(account, day_count, true)).change(function() { var num = $(this).val(); if (self.is_valid_value(num)){ - num = Number(self.parse_client(num)); - } + num = (num == 0)?0:Number(self.parse_client(num)); + } if (isNaN(num)) { $(this).val(self.sum_box(account, day_count, true)); } else { account.days[day_count].lines[0].unit_amount += num - self.sum_box(account, day_count); self.display_totals(); self.sync(); - if(!isNaN($(this).val())){ + if(!isNaN($(this).val())){ $(this).val(self.sum_box(account, day_count, true)); } } @@ -269,7 +270,7 @@ openerp.hr_timesheet_sheet = function(instance) { _.each(account.days[day_count].lines, function(line) { line_total += line.unit_amount; }); - return (show_value_in_hour)?this.format_client(line_total):line_total; + return (show_value_in_hour && line_total != 0)?this.format_client(line_total):line_total; }, display_totals: function() { var self = this; From 0e8d719cd1f783aedbf12dd1e2e348022fd00462 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 24 May 2013 15:55:20 +0200 Subject: [PATCH 4/9] [FIX] web_calendar: today button should return the date_part only bzr revid: mat@openerp.com-20130524135520-8853j3kfxlmp2lpm --- addons/web_calendar/static/src/js/calendar.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index a9287c0021c..40539f7f0f6 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -15,6 +15,12 @@ old_scheduler_dblclick.apply(this, arguments); } }; + + scheduler._click.dhx_cal_today_button = function() { + if (scheduler.callEvent("onBeforeTodayDisplayed", [])) { + scheduler.setCurrentView( scheduler.date.date_part(new Date()) ); + } + }; } }()); From e528e410c2eebefe9ee1fde4f7e280e55417d46b Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 24 May 2013 16:28:56 +0200 Subject: [PATCH 5/9] [IMP] explain monkey patch bzr revid: mat@openerp.com-20130524142856-gra4nuvl7upuldp5 --- addons/web_calendar/static/src/js/calendar.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/web_calendar/static/src/js/calendar.js b/addons/web_calendar/static/src/js/calendar.js index 40539f7f0f6..8da2ad43819 100644 --- a/addons/web_calendar/static/src/js/calendar.js +++ b/addons/web_calendar/static/src/js/calendar.js @@ -4,9 +4,9 @@ (function() { // Monkey patch dhtml scheduler in order to fix a bug. - // It manually implements some kind of dbl click event - // bubbling but fails to do it properly. if (this.scheduler) { + // It manually implements some kind of dbl click event + // bubbling but fails to do it properly. var old_scheduler_dblclick = scheduler._on_dbl_click; scheduler._on_dbl_click = function(e, src) { if (src && !src.className) { @@ -16,6 +16,8 @@ } }; + // It uses the date+time format, leading to month range being between + // 1/5 08:53 - 1/6 08:52 instead of 1/5 00:00 - 31/5 23:59 scheduler._click.dhx_cal_today_button = function() { if (scheduler.callEvent("onBeforeTodayDisplayed", [])) { scheduler.setCurrentView( scheduler.date.date_part(new Date()) ); From d0f4f8d0177edc126a72abbb8229042dd6f9cc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 24 May 2013 16:29:32 +0200 Subject: [PATCH 6/9] [FIX] project_issue: fixed access rights issues when truing to find suggested partners. bzr revid: tde@openerp.com-20130524142932-0g47w650hqpirft1 --- addons/project_issue/project_issue.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index f8f6510cd49..13ccfcee8d0 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -23,7 +23,7 @@ from openerp.addons.base_status.base_stage import base_stage from openerp.addons.project.project import _TASK_STATE from openerp.addons.crm import crm from datetime import datetime -from openerp.osv import fields,osv +from openerp.osv import fields, osv, orm from openerp.tools.translate import _ import binascii import time @@ -489,11 +489,14 @@ class project_issue(base_stage, osv.osv): def message_get_suggested_recipients(self, cr, uid, ids, context=None): recipients = super(project_issue, self).message_get_suggested_recipients(cr, uid, ids, context=context) - for issue in self.browse(cr, uid, ids, context=context): - if issue.partner_id: - self._message_add_suggested_recipient(cr, uid, recipients, issue, partner=issue.partner_id, reason=_('Customer')) - elif issue.email_from: - self._message_add_suggested_recipient(cr, uid, recipients, issue, email=issue.email_from, reason=_('Customer Email')) + try: + for issue in self.browse(cr, uid, ids, context=context): + if issue.partner_id: + self._message_add_suggested_recipient(cr, uid, recipients, issue, partner=issue.partner_id, reason=_('Customer')) + elif issue.email_from: + self._message_add_suggested_recipient(cr, uid, recipients, issue, email=issue.email_from, reason=_('Customer Email')) + except (osv.except_osv, orm.except_orm): # no read access rights -> just ignore suggested recipients because this imply modifying followers + pass return recipients def message_new(self, cr, uid, msg, custom_values=None, context=None): From 08167175268a669b80b672aa0c2bb0f50b60cab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 24 May 2013 16:42:24 +0200 Subject: [PATCH 7/9] [FIX] Chatter: fixed suggested recipients, when having no email, unchecking the box was not taken into account. bzr revid: tde@openerp.com-20130524144224-wbi1o27regxed7mn --- addons/mail/static/src/js/mail.js | 4 ++-- addons/mail/static/src/xml/mail.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index f3e762d1f31..1e58dc47e22 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -850,9 +850,9 @@ openerp.mail = function (session) { on_checked_recipient: function (event) { var $input = $(event.target); - var email = $input.attr("data"); + var full_name = $input.attr("data"); _.each(this.recipients, function (recipient) { - if (recipient.email_address == email) { + if (recipient.full_name == full_name) { recipient.checked = $input.is(":checked"); } }); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index ab82d650f30..f5004941a8d 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -143,7 +143,7 @@