[IMP] project_long_term: small code cleanup for project kanban view

bzr revid: rco@openerp.com-20120509072654-mp3uxp2qo8m7qlhi
This commit is contained in:
Raphael Collet
2012-05-09 09:26:54 +02:00
parent 0c1334bd62
commit 479d600986
2 changed files with 23 additions and 27 deletions
+8 -10
View File
@@ -216,25 +216,23 @@ project_user_allocation()
class project(osv.osv):
_inherit = "project.project"
def _phase_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
phase_pool = self.pool.get('project.phase')
phase_ids = phase_pool.search(cr, uid, [('project_id', 'in', ids)])
for phase in phase_pool.browse(cr, uid, phase_ids, context):
phase_ids = self.pool.get('project.phase').search(cr, uid, [('project_id', 'in', ids)])
for phase in self.pool.get('project.phase').browse(cr, uid, phase_ids, context):
res[phase.project_id.id] += 1
return res
_columns = {
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"),
'use_phases' : fields.boolean('Phase',help = "If you check this field Phases are appears in kanban view"),
'phase_count' : fields.function(_phase_count , type='integer',string="Open Phases"),
'use_phases': fields.boolean('Use Phases', help="Check this field if project manages phases"),
'phase_count': fields.function(_phase_count, type='integer', string="Open Phases"),
}
_defaults = {
'use_phases' : True,
'use_phases': True,
}
def schedule_phases(self, cr, uid, ids, context=None):
context = context or {}
if type(ids) in (long, int,):
@@ -84,12 +84,12 @@
</search>
</field>
</record>
<record id="act_resouce_allocation" model="ir.actions.act_window">
<record id="act_resouce_allocation" model="ir.actions.act_window">
<field name="name">Planning of Users</field>
<field name="res_model">project.user.allocation</field>
<field name="view_type">form</field>
<field name="view_mode">gantt,tree,form,calendar</field>
<field name="context">{}</field>
<field name="context">{}</field>
<field name="search_view_id" ref="view_project_user_allocation_search"/>
</record>
@@ -104,22 +104,21 @@
<field name="type">form</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='use_tasks']" position="after">
<field name="use_tasks" position="after">
<field name="use_phases"/>
</xpath>
</field>
</field>
</record>
<act_window
context="{'search_default_project_id': active_id, 'default_project_id': active_id}"
id="act_project_phases"
name="Phases"
res_model="project.phase"
src_model="project.project"
view_mode="tree,form"
view_type="form"
<act_window id="act_project_phases"
name="Phases"
src_model="project.project"
res_model="project.phase"
view_type="form"
view_mode="tree,form"
context="{'search_default_project_id': [active_id], 'default_project_id': active_id}"
/>
<record id="view_project_kanban_phase" model="ir.ui.view">
<field name="name">project.project.kanban.inherited</field>
<field name="model">project.project</field>
@@ -131,9 +130,8 @@
<field name="phase_count"/>
</field>
<xpath expr="//div[@id='list']" position="inside">
<t t-if="record.use_phases.raw_value">
<a id="4" name="%(act_project_phases)d" class="oe_project_buttons" type="action"><t t-if="record.phase_count.value &lt;= 1">Phase</t><t t-if="record.phase_count.value > 1">Phases</t>(<t t-esc="record.phase_count.value"/>)</a>
</t>
<a t-if="record.use_phases.raw_value" class="oe_project_buttons"
id="4" name="%(act_project_phases)d" type="action">Phases(<field name="phase_count"/>)</a>
</xpath>
</field>
</record>