From 2442fe2e4b9b44b984d0552e16be2d1e19ca7d29 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 14 Sep 2015 10:24:48 +0200 Subject: [PATCH 1/4] [FIX] resource: hour_to and hour_from in interval_get_multi The function interval_get_multi must take into account the minutes in hour_from and hour_to. hour_to and hour_from are float fields in the model "resource.calendar.attendance" and the decimal part of these two fields is for the minutes. opw:648349 --- addons/resource/resource.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 155d6ab4c68..ec414f2f38a 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -165,8 +165,10 @@ class resource_calendar(osv.osv): current_hour = dt_from.hour while float_compare(todo, 0, 4) and maxrecur: for (hour_from,hour_to) in [(item['hour_from'], item['hour_to']) for item in hours_by_cal[id] if item['dayofweek'] == str(dt_from.weekday())]: - hour_from = dt_from.replace(hour=int(hour_from)).replace(tzinfo=tzinfo).astimezone(pytz.UTC).hour - hour_to = dt_from.replace(hour=int(hour_to)).replace(tzinfo=tzinfo).astimezone(pytz.UTC).hour + h_from = dt_from.replace(hour=int(hour_from), minute=int((hour_from % 1)*60)).replace(tzinfo=tzinfo).astimezone(pytz.UTC) + hour_from = h_from.hour + f_round(float(h_from.minute)/60, 2) + h_to = dt_from.replace(hour=int(hour_to), minute=int((hour_to % 1)*60)).replace(tzinfo=tzinfo).astimezone(pytz.UTC) + hour_to = h_to.hour + f_round(float(h_to.minute)/60, 2) leave_flag = False if (hour_to>current_hour) and float_compare(todo, 0, 4): m = max(hour_from, current_hour) From acf22b7bc84164df99046120287ad1f7f5d01783 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 14 Sep 2015 15:12:40 +0200 Subject: [PATCH 2/4] [FIX] resource: current_hour in interval_get_multi The minutes of dt_from(start date) must be taken into account by current_hour and not by todo (hours). --- addons/resource/resource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index ec414f2f38a..0ff1fd71468 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -159,10 +159,10 @@ class resource_calendar(osv.osv): continue dt_leave = self._get_leaves(cr, uid, id, resource) - todo = hours + f_round(float(dt_from.minute)/60, 2) + todo = hours result = [] maxrecur = 100 - current_hour = dt_from.hour + current_hour = dt_from.hour + f_round(float(dt_from.minute)/60, 2) while float_compare(todo, 0, 4) and maxrecur: for (hour_from,hour_to) in [(item['hour_from'], item['hour_to']) for item in hours_by_cal[id] if item['dayofweek'] == str(dt_from.weekday())]: h_from = dt_from.replace(hour=int(hour_from), minute=int((hour_from % 1)*60)).replace(tzinfo=tzinfo).astimezone(pytz.UTC) From cc9113f818ad62c4bfc5ede90a1b055c8bb9414e Mon Sep 17 00:00:00 2001 From: dufresnedavid Date: Tue, 1 Sep 2015 17:10:33 -0400 Subject: [PATCH 3/4] [IMP] Prevent unclosed cursor during tests If an error happens in an overload of setUp, the already-open cursor is likely not to get properly released before the next test, deadlocking the db, because tearDown only runs if setUp has succesfully completed. Cleanups were added specifically to run every time, after tearDown has (potentially) been executed. closes #8327 Note: cleanups run in LIFO order (as they should). --- openerp/tests/common.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 3f0143ef9df..4e72b6c5fd6 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -94,9 +94,10 @@ class TransactionCase(BaseCase): TransactionCase.cr = self.cursor() TransactionCase.uid = openerp.SUPERUSER_ID - def tearDown(self): - self.cr.rollback() - self.cr.close() + @self.addCleanup + def close_cursor(): + self.cr.rollback() + self.cr.close() class SingleTransactionCase(BaseCase): From c2aff4772e549ab8ee643b7cb0f019114d638b75 Mon Sep 17 00:00:00 2001 From: Valencia Rodrigues Sah Date: Thu, 17 Sep 2015 15:35:21 +0530 Subject: [PATCH 4/4] [FIX] product: default value on required field The qty fields has become computed in 6.1, and the value set by the user is on min_qty. Set default value as it is required. Closes #8561 --- addons/product/product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index 98a33a98f8a..5222ebc3d81 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -901,7 +901,7 @@ class product_supplierinfo(osv.osv): 'company_id':fields.many2one('res.company','Company',select=1), } _defaults = { - 'qty': lambda *a: 0.0, + 'min_qty': lambda *a: 0.0, 'sequence': lambda *a: 1, 'delay': lambda *a: 1, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'product.supplierinfo', context=c),