Files
tryton/work.py
T

55 lines
1.7 KiB
Python
Raw Normal View History

2008-10-22 20:11:42 +02:00
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
2008-06-03 17:46:57 +02:00
"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)
2009-02-03 19:00:45 +01:00
if not self.parent.context:
self.parent.context = "{'project_type': locals().get('project_type')}"
elif 'project_type' not in self.parent.context:
2008-11-27 20:14:33 +01:00
sep = ''
2009-02-03 19:00:45 +01:00
if self.parent.context[-2] != ',':
2008-11-27 20:14:33 +01:00
sep = ','
2009-02-03 19:00:45 +01:00
self.parent.context = self.parent.context[:-1] + \
2008-11-27 20:14:33 +01:00
sep + "'project_type': locals().get('project_type')" + \
2009-02-03 19:00:45 +01:00
self.parent.context[-1:]
self._reset_columns()
TimesheetWork()
2008-06-03 17:46:57 +02:00
2008-06-09 17:18:04 +02:00
class Work(OSV):
'Work'
_name = 'project.work'
2008-06-03 17:46:57 +02:00
_description = __doc__
2008-06-09 16:54:49 +02:00
_inherits = {'timesheet.work': 'work'}
2008-06-03 17:46:57 +02:00
2008-06-09 17:18:04 +02:00
work = fields.Many2One('timesheet.work', 'Work',
2008-06-03 17:46:57 +02:00
required=True)
project_type = fields.Selection([
('project', 'Project'),
], 'Type', required=True, select=1)
2008-10-22 20:11:42 +02:00
party = fields.Many2One('party.party', 'Party',
states={
'invisible': "project_type != 'project'",
})
2008-10-22 20:11:42 +02:00
party_address = fields.Many2One('party.address', 'Contact Address',
domain="[('party', '=', party)]",
states={
'invisible': "project_type != 'project'",
})
2008-06-03 17:46:57 +02:00
comment = fields.Text('Comment')
2008-06-12 16:32:32 +02:00
def default_project_type(self, cursor, user, context=None):
return 'project'
2008-06-09 17:18:04 +02:00
Work()