[IMP] project kanban: add link to dispalay related docs with it's count

bzr revid: rgaopenerp-20121030133222-3mq4l2frtdvmeo1q
This commit is contained in:
RGA(OpenERP) 2012-10-30 19:02:22 +05:30
parent 43fcc1c6a9
commit 7d4d1e346a
2 changed files with 17 additions and 1 deletions

View File

@ -178,7 +178,18 @@ class project(osv.osv):
res = super(project, self).unlink(cr, uid, ids, *args, **kwargs)
mail_alias.unlink(cr, uid, alias_ids, *args, **kwargs)
return res
def _get_attached_docs(self, cr, uid, ids, field_name, arg, context):
res = {}
attachment = self.pool.get('ir.attachment')
task = self.pool.get('project.task')
for id in ids:
project_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.project'), ('res_id', 'in', [id])], context=context)
task_ids = task.search(cr, uid, [('project_id', 'in', [id])])
task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context)
res[id] = len(project_attachments + task_attachments)
return res
def _task_count(self, cr, uid, ids, field_name, arg, context=None):
res = dict.fromkeys(ids, 0)
task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)])
@ -249,6 +260,7 @@ class project(osv.osv):
help="The kind of document created when an email is received on this project's email alias"),
'privacy_visibility': fields.selection([('public','Public'), ('followers','Followers Only')], 'Privacy / Visibility', required=True),
'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,),
'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int')
}
def _get_type_common(self, cr, uid, context):

View File

@ -223,6 +223,7 @@
<field name="task_count"/>
<field name="alias_id"/>
<field name="alias_domain"/>
<field name="doc_count"/>
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color_#{kanban_getcolor(record.color.raw_value)} oe_kanban_card oe_kanban_project oe_kanban_global_click">
@ -240,6 +241,9 @@
<div class="oe_kanban_project_list">
<a t-if="record.use_tasks.raw_value" name="%(act_project_project_2_project_task_all)d" type="action" style="margin-right: 10px"> <field name="task_count"/> Tasks</a>
</div>
<div class="oe_kanban_project_list">
<a t-if="record.doc_count.raw_value" name="attachment_tree_view" type="object" style="margin-right: 10px"> <field name="doc_count"/> Documents</a>
</div>
<div class="oe_kanban_footer_left">
<span groups="project.group_time_work_estimation_tasks">
<span class="oe_e">R</span>