[IMP] account: Improve all journal reports => Add onchage for period from and to which change start and end date respectively and als0 add get start and end date in common report class
bzr revid: mra@mra-laptop-20100712110039-wicup1ibw2w3d5nw
This commit is contained in:
@@ -59,7 +59,9 @@ class journal_print(report_sxw.rml_parse, account_journal_common_default):
|
||||
'get_start_period': self.get_start_period,
|
||||
'get_end_period': self.get_end_period,
|
||||
'get_account': self._get_account,
|
||||
'get_filter': self._get_filter
|
||||
'get_filter': self._get_filter,
|
||||
'get_start_date': self._get_start_date,
|
||||
'get_end_date': self._get_end_date
|
||||
})
|
||||
|
||||
def lines(self, period_id, journal_id=[]):
|
||||
|
||||
@@ -219,9 +219,9 @@
|
||||
</blockTable>
|
||||
<blockTable colWidths="67.0,67.0,67.0,67.0,68.0,68.0,68.0,68.0" style="Table_Subheader_Content_detail">
|
||||
<tr>
|
||||
<td><para style="terp_default_Centre_8">[[ data and 'form' in data and data['form']['date_from'] or '' ]]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ data and 'form' in data and data['form']['date_to'] or '']]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ data and 'form' in data and data['form']['sort_selection'] or 'date' ]]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ get_start_date(data) ]] </para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ get_end_date(data)]] </para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ data and 'form' in data and data['form']['sort_selection'] or 'Date' ]]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ get_account(data) or removeParentNode('para') ]]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ get_start_period(data) or removeParentNode('para') ]]</para></td>
|
||||
<td><para style="terp_default_Centre_8">[[ get_end_period(data) or removeParentNode('para') ]]</para></td>
|
||||
|
||||
@@ -55,11 +55,15 @@ class account_journal_common_default(object):
|
||||
(tuple(period_id), tuple(journal_id)))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
# def get_start_date(self, form):
|
||||
# return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_from']).name
|
||||
#
|
||||
# def get_end_date(self, form):
|
||||
# return pooler.get_pool(self.cr.dbname).get('account.period').browse(self.cr,self.uid,form['period_to']).name
|
||||
def _get_start_date(self, data):
|
||||
if data.get('form', False) and data['form'].get('date_from', False):
|
||||
return data['form']['date_from']
|
||||
return ''
|
||||
|
||||
def _get_end_date(self, data):
|
||||
if data.get('form', False) and data['form'].get('date_to', False):
|
||||
return data['form']['date_to']
|
||||
return ''
|
||||
|
||||
def get_start_period(self, data):
|
||||
if data.get('form', False) and data['form'].get('period_from', False):
|
||||
|
||||
@@ -62,6 +62,24 @@ class account_common_report(osv.osv_memory):
|
||||
return res
|
||||
return {}
|
||||
|
||||
def onchange_period_from(self, cr, uid, ids, filter='filter_no', period_from=False, context=None):
|
||||
period_obj = self.pool.get('account.period')
|
||||
res = {}
|
||||
if filter == 'filter_period':
|
||||
period_date_start = period_obj.read(cr, uid, period_from, ['date_start'])['date_start']
|
||||
res['value'] = {'date_from': period_date_start}
|
||||
return res
|
||||
return res
|
||||
|
||||
def onchange_period_to(self, cr, uid, ids, filter='filter_no', period_to=False, context=None):
|
||||
period_obj = self.pool.get('account.period')
|
||||
res = {}
|
||||
if filter == 'filter_period':
|
||||
period_date_to = period_obj.read(cr, uid, period_to, ['date_stop'])['date_stop']
|
||||
res['value'] = {'date_to': period_date_to}
|
||||
return res
|
||||
return res
|
||||
|
||||
def _get_account(self, cr, uid, context=None):
|
||||
tmp = self.pool.get('account.account').search(cr, uid, [], limit=1 )
|
||||
if not tmp:
|
||||
@@ -107,6 +125,8 @@ class account_common_report(osv.osv_memory):
|
||||
raise osv.except_osv(_('Error'),_('Start period should be smaller then End period'))
|
||||
period_date_start = period_obj.read(cr, uid, data['form']['period_from'], ['date_start'])['date_start']
|
||||
period_date_stop = period_obj.read(cr, uid, data['form']['period_to'], ['date_stop'])['date_stop']
|
||||
# result['date_from'] = period_date_start
|
||||
# result['date_to'] = period_date_stop
|
||||
cr.execute('SELECT id FROM account_period WHERE date_start >= %s AND date_stop <= %s', (period_date_start, period_date_stop))
|
||||
result['periods'] = map(lambda x: x[0], cr.fetchall())
|
||||
return result
|
||||
@@ -115,15 +135,19 @@ class account_common_report(osv.osv_memory):
|
||||
raise (_('Error'), _('not implemented'))
|
||||
|
||||
def check_report(self, cr, uid, ids, context=None):
|
||||
obj_acc_move_line = self.pool.get('account.move.line')
|
||||
if context is None:
|
||||
context = {}
|
||||
data = {}
|
||||
data['ids'] = context.get('active_ids', [])
|
||||
data['model'] = context.get('active_model', 'ir.ui.menu')
|
||||
data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to', 'fiscalyear_id', 'journal_ids', 'period_from', 'period_to', 'filter', 'chart_account_id'])[0]
|
||||
if data['form']['filter'] == 'filter_period': # FIX Me => onchange on period from and to is not working so did this ..but correct it!
|
||||
start_date = self.onchange_period_from(cr, uid, ids, data['form']['filter'], data['form']['period_from'])
|
||||
end_date = self.onchange_period_to(cr, uid, ids, data['form']['filter'], data['form']['period_to'])
|
||||
data['form']['date_from'] = start_date['value']['date_from']
|
||||
data['form']['date_to'] = end_date['value']['date_to']
|
||||
used_context = self._build_context(cr, uid, ids, data, context)
|
||||
query_line = obj_acc_move_line._query_get(cr, uid, obj='l', context=used_context)
|
||||
query_line = self.pool.get('account.move.line')._query_get(cr, uid, obj='l', context=used_context)
|
||||
if used_context.get('periods', False):
|
||||
data['form']['periods'] = used_context['periods']
|
||||
else:
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
<field name="date_from" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>
|
||||
<field name="date_to" attrs="{'readonly':[('filter', '!=', 'filter_date')], 'required':[('filter', '=', 'filter_date')]}" colspan="4"/>
|
||||
<separator string="Periods" colspan="4"/>
|
||||
<field name="period_from" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
|
||||
<field name="period_to" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
|
||||
<field name="period_from" on_change="onchange_period_from(filter, period_from)" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
|
||||
<field name="period_to" on_change="onchange_period_to(filter, period_to)" domain="[('fiscalyear_id', '=', fiscalyear_id)]" attrs="{'readonly':[('filter','!=','filter_period')], 'required':[('filter', '=', 'filter_period')]}" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user