[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
This commit is contained in:
Martin Trigaux 2014-01-15 09:57:48 +01:00
parent 5334330d9d
commit 3a95bbaf63
1 changed files with 6 additions and 1 deletions

View File

@ -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