[IMP]
authorSanjay Gohel (Open ERP) <sgo@tinyerp.com>
Wed, 4 Apr 2012 06:16:17 +0000 (11:46 +0530)
committerSanjay Gohel (Open ERP) <sgo@tinyerp.com>
Wed, 4 Apr 2012 06:16:17 +0000 (11:46 +0530)
bzr revid: sgo@tinyerp.com-20120404061617-r463yhakhd49ren7

addons/project_timesheet/project_timesheet.py
addons/project_timesheet/project_timesheet_view.xml

index 5e5285b..85231fe 100644 (file)
@@ -47,11 +47,20 @@ class project_project(osv.osv):
                 res[project.id]['hrs_to_invoice'] = hrs_to_invoice
             
         return res
+    
+    def _compute_timesheet(self, cr, uid, ids, field_name, arg, context=None):
+        res={}
+        aal_pool=self.pool.get('account.analytic.line')
+        for project in self.browse(cr, uid, ids, context=context):
+            timesheet = aal_pool.search(cr, uid, [("account_id","=", project.analytic_account_id.id)])
+            res[project.id] = len(timesheet)
+        return res
 
     _columns = {
         'timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"),
         'amt_to_invoice': fields.function(_to_invoice,string="Amount to Invoice",multi="sums"),
-        'hrs_to_invoice': fields.function(_to_invoice,string="Hours to Invoice",multi="sums")
+        'hrs_to_invoice': fields.function(_to_invoice,string="Hours to Invoice",multi="sums"),
+        'total_timesheet': fields.function(_compute_timesheet , type='integer',string="Issue"),
     }
     _defaults = {
         'timesheets' : True,
index 6fbec2d..efe8edb 100644 (file)
@@ -38,7 +38,7 @@
         <xpath expr="//h4[@id='list']" position="inside">
         <a>
             <t t-if="record.timesheets.raw_value">
-                <button name="open_timesheets" class="oe_project_buttons" type="object">, Timesheet</button>
+                <button name="open_timesheets" class="oe_project_buttons" type="object">,<field name="total_timesheet"/> Timesheet</button>
             </t>
             </a>
         </xpath>