From 234526e6228d258e61412e4b3a59af9e09a71bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 7 Jul 2016 10:29:13 +0200 Subject: [PATCH] Use a self referencing Many2One as graph x axis The client group by the value of the field, so it is unique in contrary of the name. issue5525 review27441002 --- view/work_graph.xml | 2 +- work.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/view/work_graph.xml b/view/work_graph.xml index ccdd6a0128..8dd66a2fb3 100644 --- a/view/work_graph.xml +++ b/view/work_graph.xml @@ -3,7 +3,7 @@ this repository contains the full copyright notices and license terms. --> - + diff --git a/work.py b/work.py index 6f14723e9f..ad9ad635de 100644 --- a/work.py +++ b/work.py @@ -46,6 +46,9 @@ class Work(ModelSQL, ModelView): states={ 'readonly': Not(Bool(Eval('active'))), }) + # Self referring field to use for aggregation in graph view + work = fields.Function(fields.Many2One('timesheet.work', 'Work'), + 'get_work') @classmethod def __setup__(cls): @@ -157,6 +160,9 @@ class Work(ModelSQL, ModelView): durations[work_id] = duration return durations + def get_work(self, name): + return self.id + def get_rec_name(self, name): if self.origin: return self.origin.rec_name