From 7cfbab01ba5e311d20620384efd7fe7ecf042240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 9 Jun 2008 19:18:12 +0200 Subject: [PATCH] Add project_type on work and model access on project.work --- project.xml | 12 ++++++++++++ work.py | 31 ++++++++++++++++++++++++++++-- work.xml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 92 insertions(+), 5 deletions(-) diff --git a/project.xml b/project.xml index 69fcac0d79..8750828928 100644 --- a/project.xml +++ b/project.xml @@ -1,7 +1,19 @@ + + Project Administration + + + + + + + diff --git a/work.py b/work.py index d32e617c9b..1f6cf4cde1 100644 --- a/work.py +++ b/work.py @@ -1,6 +1,24 @@ "Project" from trytond.osv import fields, OSV +import copy + + +class TimesheetWork(OSV): + _name = 'timesheet.work' + + def __init__(self): + super(TimesheetWork, self).__init__() + self.parent = copy.copy(self.parent) + if not self.parent._context: + self.parent._context = "{'project_type': locals().get('project_type')}" + else: + self.parent._context = self.parent._context[:-1] + \ + ",'project_type': locals().get('project_type')" + \ + self.parent._context[-1:] + self._reset_columns() + +TimesheetWork() class Work(OSV): @@ -11,9 +29,18 @@ class Work(OSV): work = fields.Many2One('timesheet.work', 'Work', required=True) - party = fields.Many2One('relationship.party', 'Party') + project_type = fields.Selection([ + ('project', 'Project'), + ], 'Type', required=True, select=1) + party = fields.Many2One('relationship.party', 'Party', + states={ + 'invisible': "project_type != 'project'", + }) party_address = fields.Many2One('relationship.address', 'Contact Address', - domain="[('party', '=', party)]") + domain="[('party', '=', party)]", + states={ + 'invisible': "project_type != 'project'", + }) comment = fields.Text('Comment') Work() diff --git a/work.xml b/work.xml index 3946efa2a7..fdbab6d6b1 100644 --- a/work.xml +++ b/work.xml @@ -8,6 +8,8 @@ + + @@ -22,10 +24,16 @@