Remove usage of type in context in favor of domain inversion

This commit is contained in:
Cédric Krier committed 2012-03-30 11:47:47 +02:00
1 parent 2fedc4ba72
commit 3dcb119128
3 files changed
+7 -24

No files matched your search

+2
View File
@@ -1,3 +1,5 @@
* Remove usage of type in context
Version 2.2.0 - 2011-10-24
* Bug fixes (see mercurial logs for details)
+2 -21
View File
@@ -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)
+3 -3
View File
@@ -174,7 +174,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Projects</field>
<field name="res_model">project.work</field>
<field name="domain">[('type', '=', 'project')]</field>
<field name="context">{'type': 'project'}</field>
<field name="context"></field>
</record>
<record model="ir.action.act_window.view"
id="act_project_form_view1">
@@ -195,7 +195,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">Tasks</field>
<field name="res_model">project.work</field>
<field name="domain">[('type', '=', 'task')]</field>
<field name="context">{'type': 'task'}</field>
<field name="context"></field>
</record>
<record model="ir.action.act_window.view"
id="act_task_form_view1">
@@ -215,7 +215,7 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.action.act_window" id="act_open_child_work">
<field name="name">Tasks</field>
<field name="res_model">project.work</field>
<field name="context">{'type': 'task'}</field>
<field name="context"></field>
<field name="domain">[('parent', '=', Eval('active_id')), ('type', '=', 'task')]</field>
</record>
<record model="ir.action.keyword"