[FIX] account: Put domain for company analysis and improved read_group

lp bug: https://launchpad.net/bugs/694876 fixed

bzr revid: pso@tinyerp.com-20100212061751-7wd3qzvtjit8tra3
This commit is contained in:
pso 2010-02-12 11:47:51 +05:30
parent 11296198e0
commit 4363de12dd
3 changed files with 14 additions and 19 deletions

View File

@ -27,6 +27,7 @@
<field name="view_mode">tree,graph</field>
<field name="context">{'group_by':['user_type'], 'group_by_no_leaf':1}</field>
<field name="view_id" ref="account.view_account_entries_report_tree"/>
<field name="domain">[('year','=',time.strftime('%Y'))]</field>
</record>
<record id="action_treasory_graph" model="ir.actions.act_window">
<field name="name">Treasury</field>

View File

@ -94,25 +94,19 @@ class account_entries_report(osv.osv):
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, *args, **kwargs):
todel=[]
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
fiscalyear_obj = self.pool.get('account.fiscalyear')
period_obj = self.pool.get('account.period')
for arg in domain:
if arg[0] == 'period_id' and arg[2] == 'current_period':
current_period = period_obj.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 = fiscalyear_obj.find(cr, uid)
ids = fiscalyear_obj.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, *args, **kwargs)
if context.get('period', False) == 'current_period':
current_period = period_obj.find(cr, uid)[0]
domain.append(['period_id','in',[current_period]])
elif context.get('year', False) == 'current_year':
current_year = fiscalyear_obj.find(cr, uid)
ids = fiscalyear_obj.read(cr, uid, [current_year], ['period_ids'])[0]['period_ids']
domain.append(['period_id','in',ids])
else:
domain = domain
return super(account_entries_report, self).read_group(cr, uid, domain, fields, groupby, offset, limit, context, orderby)
def init(self, cr):
tools.drop_view_if_exists(cr, 'account_entries_report')

View File

@ -70,11 +70,11 @@
<group colspan="10" col="12">
<filter icon="terp-go-year" string="This F.Year"
name="thisyear"
domain="[('period_id','in','current_year')]"
context="{'year':'current_year'}"
help="Journal Entries with period in current year"/>
<filter icon="terp-go-month" string="This Period"
name="period"
domain="[('period_id','in','current_period')]"
context="{'period':'current_period'}"
help="Journal Entries with period in current period"/>
<separator orientation="vertical"/>
<filter string="Unposted" icon="terp-document-new" domain="[('move_state','=','draft')]" help = "entries"/>