'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("""
<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','<=', time.strftime('%%Y-%%m-%%d')),('date','>',(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','<=', time.strftime('%%Y-%%m-%%d')), ('date','>',(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"/>