[FIX] Corrected the Date criteria filtering behaviour for Account Balance Report...
authorJay (Open ERP) <jvo@tinyerp.com>
Mon, 16 Mar 2009 11:41:01 +0000 (17:11 +0530)
committerJay (Open ERP) <jvo@tinyerp.com>
Mon, 16 Mar 2009 11:41:01 +0000 (17:11 +0530)
bzr revid: jvo@tinyerp.com-20090316114101-lkjq42vckyybnchi

addons/account/account_move_line.py
addons/account/report/account_balance.py

index 084185a..354f721 100644 (file)
@@ -40,16 +40,22 @@ class account_move_line(osv.osv):
         else:
             fiscalyear_clause = '%s' % context['fiscalyear']
         state=context.get('state',False)
-        where_move_state=''
+        where_move_state = ''
+        where_move_lines_by_date = ''
+
+        if context.get('date_from', False) and context.get('date_to', False):
+            where_move_lines_by_date = " AND " +obj+".move_id in ( select id from account_move  where date >= '" +context['date_from']+"' AND date <= '"+context['date_to']+"')"
+            
         if state:
             if state.lower() not in ['all']:
                 where_move_state= " AND "+obj+".move_id in (select id from account_move where account_move.state = '"+state+"')"
-
+        
+                
         if context.get('periods', False):
             ids = ','.join([str(x) for x in context['periods']])
-            return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s" % (fiscalyear_clause, ids,where_move_state)
+            return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) AND id in (%s)) %s %s" % (fiscalyear_clause, ids,where_move_state,where_move_lines_by_date)
         else:
-            return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s)" % (fiscalyear_clause,where_move_state)
+            return obj+".state<>'draft' AND "+obj+".period_id in (SELECT id from account_period WHERE fiscalyear_id in (%s) %s %s)" % (fiscalyear_clause,where_move_state,where_move_lines_by_date)
 
     def default_get(self, cr, uid, fields, context={}):
         data = self._default_get(cr, uid, fields, context)
index 64db67e..e74ad78 100644 (file)
@@ -127,6 +127,8 @@ class account_balance(report_sxw.rml_parse):
                 ctx['fiscalyear'] = form['fiscalyear']
                 ctx['periods'] = form['periods'][0][2]
             elif form['state']== 'bydate':
+                ctx['date_from'] = form['date_from']
+                ctx['date_to'] =  form['date_to'] 
                 self.transform_date_into_date_array(form)
             elif form['state'] == 'all' :
                 self.transform_both_into_date_array(form)