From 9ca15bc66ea6230cde43fc866883db34b74a198b Mon Sep 17 00:00:00 2001 From: Udo Spallek Date: Thu, 7 Jul 2011 12:39:22 +0200 Subject: [PATCH] Move field timesheet_lines and method copy from project module. issue2025 review42002 --- work.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/work.py b/work.py index c1a76c0627..4df660cbf2 100644 --- a/work.py +++ b/work.py @@ -2,7 +2,7 @@ #this repository contains the full copyright notices and license terms. from trytond.model import ModelView, ModelSQL, fields from trytond.wizard import Wizard -from trytond.pyson import PYSONEncoder +from trytond.pyson import PYSONEncoder, Not, Bool, Eval from trytond.transaction import Transaction from trytond.pool import Pool @@ -24,6 +24,13 @@ class Work(ModelSQL, ModelView): timesheet_available = fields.Boolean('Available on timesheets', help="Allow to fill in timesheets with this work") company = fields.Many2One('company.company', 'Company', required=True) + timesheet_lines = fields.One2Many('timesheet.line', 'work', + 'Timesheet Lines', + depends=['timesheet_available', 'active'], + states={ + 'invisible': Not(Bool(Eval('timesheet_available'))), + 'readonly': Not(Bool(Eval('active'))), + }) def __init__(self): super(Work, self).__init__() @@ -113,6 +120,14 @@ class Work(ModelSQL, ModelView): res[work.id] = _name(work) return res + def copy(self, ids, default=None): + if default is None: + default = {} + default = default.copy() + if 'timesheet_lines' not in default: + default['timesheet_lines'] = False + return super(Work, self).copy(ids, default=default) + def write(self, ids, vals): child_ids = None if not vals.get('active', True):