[FIX]: improvement and fix proposed by the pap@tinyerp.com
authorpap@tinyerp.com <>
Sat, 14 Aug 2010 14:30:22 +0000 (20:00 +0530)
committerMantavya Gajjar <mga@tinyerp.com>
Sat, 14 Aug 2010 14:30:22 +0000 (20:00 +0530)
bzr revid: mga@tinyerp.com-20100814143022-7jks4ktnghiyqhtt

addons/account/report/account_entries_report.py
addons/account/report/account_entries_report_view.xml
addons/account/test/account_fiscalyear_close.yml

index 0aebe50..1047453 100644 (file)
@@ -70,6 +70,42 @@ class account_entries_report(osv.osv):
         'company_id': fields.many2one('res.company', 'Company', readonly=True),
     }
     _order = 'date desc'
+    
+    def search(self, cr, uid, args, offset=0, limit=None, order=None,
+            context=None, count=False):
+        for arg in args:
+            if arg[0] == 'period_id' and arg[2] == 'current_period':
+                current_period = self.pool.get('account.period').find(cr, uid)[0]
+                args.append(['period_id','in',[current_period]])
+                break
+            elif arg[0] == 'period_id' and arg[2] == 'current_year':
+                current_year = self.pool.get('account.fiscalyear').find(cr, uid)
+                ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
+                args.append(['period_id','in',ids])
+        for a in [['period_id','in','current_year'], ['period_id','in','current_period']]:
+            if a in args:
+                args.remove(a)
+        return super(account_entries_report, self).search(cr, uid, args=args, offset=offset, limit=limit, order=order,
+            context=context, count=count)
+    
+    def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
+        todel=[]
+        for arg in domain:
+            if arg[0] == 'period_id' and arg[2] == 'current_period':
+                current_period = self.pool.get('account.period').find(cr, uid)[0]
+                domain.append(['period_id','in',[current_period]])
+                todel.append(arg)
+                break
+            elif arg[0] == 'period_id' and arg[2] == 'current_year':
+                current_year = self.pool.get('account.fiscalyear').find(cr, uid)
+                ids = self.pool.get('account.fiscalyear').read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
+                domain.append(['period_id','in',ids])
+                todel.append(arg)
+        for a in [['period_id','in','current_year'], ['period_id','in','current_period']]:
+            if a in domain:
+                domain.remove(a)
+        return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context)
+    
     def init(self, cr):
         tools.drop_view_if_exists(cr, 'account_entries_report')
         cr.execute("""
index 6259466..7a1746d 100644 (file)
         <field name="arch" type="xml">
             <search string="Entries Analysis">
                 <group colspan="10" col="12">
-                <filter icon="terp-go-year" string="Year"
-                                               name="year"
-                                domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
-                                help="Entries created in this year"/>
-                <filter icon="terp-go-month" string="Period"
-                        name="period"
-                        domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')), ('date','&gt;',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
-                        help="Entries created in this period"/>
+                       <filter icon="terp-go-year" string="This Year"
+                                       name="year"
+                                                       domain="[('period_id','in','current_year')]"                                    
+                               help="Entries created in current year"/>
+                       <filter icon="terp-go-month" string="This Month"
+                               name="period"
+                               domain="[('period_id','in','current_period')]"
+                               help="Entries created in current period"/>
                     <separator orientation="vertical"/>
                     <filter string="Draft" icon="terp-document-new" domain="[('state','=','draft')]" help = "Draft entries"/>
                     <filter string="Posted" icon="terp-camera_test" domain="[('state','=','posted')]" help = "Posted entries"/>
index 5af4787..a305dd8 100644 (file)
@@ -47,7 +47,7 @@
   I check the opening entries By using "Entries by Line wizard"
 -
   !record {model: account.move.journal, id: account_move_journal_0}:
-    journal_id: account.sales_journal
+   {}
 -
   I clicked on Open Journal Button to check the entries