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
This commit is contained in:
Cédric Krier committed 2016-07-07 10:29:13 +02:00
1 parent 3c3e0903cc
commit 234526e622
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<graph type="pie">
<x>
<field name="name"/>
<field name="work"/>
</x>
<y>
<field name="duration" timedelta="company_work_time"/>
+6
View File
@@ -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