From 3a95bbaf63f0555ad00f0765525417942e2a047e Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 15 Jan 2014 09:57:48 +0100 Subject: [PATCH] [FIX] base_calendar: when sorting on a many2one field (format (id, name)), sort on the name value instead of full tuple bzr revid: mat@openerp.com-20140115085748-029ntjqc71huep25 --- addons/base_calendar/base_calendar.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py index 2e1503df504..20fcb323b5d 100644 --- a/addons/base_calendar/base_calendar.py +++ b/addons/base_calendar/base_calendar.py @@ -1276,7 +1276,12 @@ rule or repeating pattern of time to exclude from the recurring rule."), def comparer(left, right): for fn, mult in comparers: - result = cmp(fn(left), fn(right)) + if type(fn(left)) == tuple and type(fn(right)) == tuple: + # comparing many2one values, sorting on name_get result + leftv, rightv = fn(left)[1], fn(right)[1] + else: + leftv, rightv = fn(left), fn(right) + result = cmp(leftv, rightv) if result: return mult * result return 0