Display state on project too and add a constraint on it
review290002
This commit is contained in:
1 parent
043280bcfc
commit
0715edbb9b
2 files changed
+15
-21
No files matched your search
@@ -61,11 +61,7 @@ class Work(ModelSQL, ModelView):
|
||||
state = fields.Selection([
|
||||
('opened', 'Opened'),
|
||||
('done', 'Done'),
|
||||
], 'State',
|
||||
states={
|
||||
'invisible': Eval('type') != 'task',
|
||||
'required': Eval('type') == 'task',
|
||||
}, select=True, depends=['type'])
|
||||
], 'State', required=True, select=True)
|
||||
sequence = fields.Integer('Sequence', required=True)
|
||||
|
||||
def default_type(self):
|
||||
@@ -110,6 +106,19 @@ class Work(ModelSQL, ModelView):
|
||||
'timesheet work by task/project!'),
|
||||
]
|
||||
self._order.insert(0, ('sequence', 'ASC'))
|
||||
self._constraints += [
|
||||
('check_state',
|
||||
'A work can not be closed if its children are still opened'),
|
||||
]
|
||||
|
||||
def check_state(self, ids):
|
||||
for work in self.browse(ids):
|
||||
if ((work.state == 'opened'
|
||||
and (work.parent and work.parent.state == 'done'))
|
||||
or (work.state == 'done'
|
||||
and any(c.state == 'opened' for c in work.children))):
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_parent(self, ids, name):
|
||||
res = dict.fromkeys(ids, None)
|
||||
|
||||
@@ -59,21 +59,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<!-- list view for projects (wihtout type and state fields) -->
|
||||
<record model="ir.ui.view" id="work_view_list3">
|
||||
<field name="model">project.work</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<tree string="Projects">
|
||||
<field name="name"/>
|
||||
<field name="hours" widget="float_time" float_time="company_work_time"/>
|
||||
<field name="total_effort" widget="float_time" float_time="company_work_time"/>
|
||||
<field name="active" tree_invisible="1"/>
|
||||
</tree>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="work_view_form">
|
||||
<field name="model">project.work</field>
|
||||
<field name="type">form</field>
|
||||
@@ -190,7 +175,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_project_form_view1">
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="view" ref="work_view_list3"/>
|
||||
<field name="view" ref="work_view_list2"/>
|
||||
<field name="act_window" ref="act_project_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
|
||||
Reference in new issue
Block a user