From 3dcb119128677e7729ac365b56437dfd8e694758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 30 Mar 2012 11:47:47 +0200 Subject: [PATCH] Remove usage of type in context in favor of domain inversion --- CHANGELOG | 2 ++ work.py | 23 ++--------------------- work.xml | 6 +++--- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index db70548193..3f94353ea9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove usage of type in context + Version 2.2.0 - 2011-10-24 * Bug fixes (see mercurial logs for details) diff --git a/work.py b/work.py index dd50d312c4..16c6dec3bb 100644 --- a/work.py +++ b/work.py @@ -8,20 +8,6 @@ from trytond.transaction import Transaction from trytond.pool import Pool -class TimesheetWork(ModelSQL, ModelView): - _name = 'timesheet.work' - - def __init__(self): - super(TimesheetWork, self).__init__() - - self.parent = copy.copy(self.parent) - self.parent.context = copy.copy(self.parent.context) - self.parent.context['type'] = Eval('type') - self._reset_columns() - -TimesheetWork() - - class Work(ModelSQL, ModelView): 'Work Effort' _name = 'project.work' @@ -34,10 +20,7 @@ class Work(ModelSQL, ModelView): ('project', 'Project'), ('task', 'Task') ], - 'Type', required=True, select=True, - states={ - 'invisible': Eval('context', {}).get('type', False), - }) + 'Type', required=True, select=True) party = fields.Many2One('party.party', 'Party', states={ 'invisible': Eval('type') != 'project', @@ -65,8 +48,6 @@ class Work(ModelSQL, ModelView): sequence = fields.Integer('Sequence', required=True) def default_type(self): - if Transaction().context.get('type') == 'project': - return 'project' return 'task' def default_state(self): @@ -227,7 +208,7 @@ class Work(ModelSQL, ModelView): id2work = {} leafs = set() for work in works: - res[work.id] = work.effort + res[work.id] = work.effort or 0 id2work[work.id] = work if not work.children: leafs.add(work.id) diff --git a/work.xml b/work.xml index 55316fde1a..2ea1f2587b 100644 --- a/work.xml +++ b/work.xml @@ -174,7 +174,7 @@ this repository contains the full copyright notices and license terms. --> Projects project.work [('type', '=', 'project')] - {'type': 'project'} + @@ -195,7 +195,7 @@ this repository contains the full copyright notices and license terms. --> Tasks project.work [('type', '=', 'task')] - {'type': 'task'} + @@ -215,7 +215,7 @@ this repository contains the full copyright notices and license terms. --> Tasks project.work - {'type': 'task'} + [('parent', '=', Eval('active_id')), ('type', '=', 'task')]