[IMP]: Improve search view of Task hours report of project_timesheet module and file...
authoratp (Open ERP) <atp@tinyerp.co.in>
Fri, 12 Nov 2010 10:14:16 +0000 (15:44 +0530)
committeratp (Open ERP) <atp@tinyerp.co.in>
Fri, 12 Nov 2010 10:14:16 +0000 (15:44 +0530)
bzr revid: atp@tinyerp.co.in-20101112101416-51opsl6u147argqm

addons/document/std_index.py
addons/project_timesheet/report/task_report_view.xml

index 2a588a0..7cfcd36 100644 (file)
@@ -96,8 +96,13 @@ class DocIndex(indexer):
 
     def _doIndexFile(self,fname):
         fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
-        return _to_unicode(fp.read())
-
+        try:
+            file_data = _to_unicode(fp.read())
+        finally:
+            fp.close()
+            
+        return file_data
+    
 cntIndex.register(DocIndex())
 
 class DocxIndex(indexer):
@@ -158,7 +163,12 @@ class PdfIndex(indexer):
 
     def _doIndexFile(self,fname):
         fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout
-        return _to_unicode( fp.read())
+        try:
+           file_data = _to_unicode( fp.read())
+        finally:
+            fp.close()
+                 
+        return file_data
 
 cntIndex.register(PdfIndex())
 
index 87949d6..8a6c3c0 100644 (file)
             <field name="arch" type="xml">
                <search string="Tasks by User">
                        <group colspan="4" col="3">
-                               <filter icon="terp-go-year" string="This Year" domain="[('year','=',time.strftime('%%Y'))]" />
-                               <filter icon="terp-go-month" string="This Month" domain="[('month','=',time.strftime('%%m'))]" />
+                        <filter icon="terp-go-year" string=" Year "
+                            name="year"
+                            domain="[('name','&lt;=', time.strftime('%%Y-%%m-%%d')),('name','&gt;=',time.strftime('%%Y-01-01'))]"
+                            help="Task Hours in current year"/>
+                        <filter icon="terp-go-month" string=" Month "
+                            name="month"
+                            domain="[('name','&lt;=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('name','&gt;=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"
+                            help="Task Hours in current month"/>
+                        <filter icon="terp-go-month"
+                            string=" Month-1 "
+                            domain="[('name','&lt;=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('name','&gt;=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]"
+                            help="Task hours of last month"/>                          
                                <separator orientation="vertical"/>
-                           <field name="user_id" select="1" widget="selection"/>
+                           <field name="user_id"/>
                        </group>
                        <newline/>
                        <group expand="1" string="Group By..." colspan="4" col="3">
-                           <filter string="User" icon="terp-personal" context="{'group_by':'user_id'}" default="1" />
-                       <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" />
-                       <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" />
-                       </group>
+                           <filter string="User" name="group_user_id" icon="terp-personal" context="{'group_by':'user_id'}" default="1" />
+                        <separator orientation="vertical"/>
+                        <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of date"/>
+                        <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of date"/>
+                    </group>
+
                </search>
             </field>
         </record>
@@ -64,8 +76,7 @@
             <field name="res_model">report.timesheet.task.user</field>
             <field name="view_type">form</field>
             <field name="view_mode">tree,graph</field>
-            <field name="context">{"search_default_user_id":uid}</field>
-            <field name="search_view_id" ref="view_report_timesheet_task_user_search"/>
+            <field name="context">{'search_default_month':1, 'search_default_group_user_id':1}</field>
         </record>
         <menuitem id="menu_timesheet_task_user" parent="hr_timesheet.menu_hr_reporting_timesheet"
                     action="action_report_timesheet_task_user" sequence="1"/>