#This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. "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')}" elif 'project_type' not in self.parent.context: sep = '' if self.parent.context[-2] != ',': sep = ',' self.parent.context = self.parent.context[:-1] + \ sep + "'project_type': locals().get('project_type')" + \ self.parent.context[-1:] self._reset_columns() TimesheetWork() class Work(OSV): 'Work' _name = 'project.work' _description = __doc__ _inherits = {'timesheet.work': 'work'} work = fields.Many2One('timesheet.work', 'Work', required=True) project_type = fields.Selection([ ('project', 'Project'), ], 'Type', required=True, select=1) party = fields.Many2One('party.party', 'Party', states={ 'invisible': "project_type != 'project'", }) party_address = fields.Many2One('party.address', 'Contact Address', domain="[('party', '=', party)]", states={ 'invisible': "project_type != 'project'", }) comment = fields.Text('Comment') def default_project_type(self, cursor, user, context=None): return 'project' Work()