From 7d4d1e346a328de83440f087c73d9a91651e1822 Mon Sep 17 00:00:00 2001
From: "RGA(OpenERP)" <>
Date: Tue, 30 Oct 2012 19:02:22 +0530
Subject: [PATCH] [IMP] project kanban: add link to dispalay related docs with
it's count
bzr revid: rgaopenerp-20121030133222-3mq4l2frtdvmeo1q
---
addons/project/project.py | 14 +++++++++++++-
addons/project/project_view.xml | 4 ++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/addons/project/project.py b/addons/project/project.py
index cafa5c5195f..0d226b084ac 100644
--- a/addons/project/project.py
+++ b/addons/project/project.py
@@ -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):
diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml
index 88b728c4294..51e8ce0b1fd 100644
--- a/addons/project/project_view.xml
+++ b/addons/project/project_view.xml
@@ -223,6 +223,7 @@
+