diff --git a/addons/account/account.py b/addons/account/account.py index 23635b298ac..449a58f136d 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -470,7 +470,7 @@ class account_journal(osv.osv): 'user_id': lambda self,cr,uid,context: uid, } def create(self, cr, uid, vals, context={}): - journal_id = super(osv.osv, self).create(cr, uid, vals, context) + journal_id = super(account_journal, self).create(cr, uid, vals, context) # journal_name = self.browse(cr, uid, [journal_id])[0].code # periods = self.pool.get('account.period') # ids = periods.search(cr, uid, [('date_stop','>=',time.strftime('%Y-%m-%d'))]) @@ -481,6 +481,7 @@ class account_journal(osv.osv): # 'period_id': period.id # }) return journal_id + def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80): if not args: args=[] diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 084185a6462..354f721db5a 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -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) diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index cdc0786c6eb..1d0ab433abe 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -324,7 +324,7 @@