[FIX] account: Third Party ledger problem with Initial Balance
lp bug: https://launchpad.net/bugs/744789 fixed bzr revid: psi@tinyerp.co.in-20110428072058-q0n8y4k01t74pe7z
This commit is contained in:
parent
26e21b097e
commit
62e9299b2b
|
@ -82,11 +82,14 @@ class account_move_line(osv.osv):
|
|||
period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1)
|
||||
if period_ids and period_ids[0]:
|
||||
first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context)
|
||||
where_move_lines_by_date = " AND " +obj+".move_id IN (SELECT id FROM account_move WHERE date < '" +first_period.date_start+"')"
|
||||
# Find the old periods where date start of those periods less then Start period
|
||||
periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)])
|
||||
periods = ','.join([str(x) for x in periods])
|
||||
if periods:
|
||||
query = 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, periods, where_move_state, where_move_lines_by_date)
|
||||
else:
|
||||
query = 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)
|
||||
else:
|
||||
ids = ','.join([str(x) for x in context['periods']])
|
||||
query = 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)
|
||||
|
@ -96,7 +99,8 @@ class account_move_line(osv.osv):
|
|||
if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
|
||||
#we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
|
||||
#so we have to invalidate this query
|
||||
query += " AND 1=2"
|
||||
raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance"))
|
||||
|
||||
if context.get('journal_ids', False):
|
||||
query += ' AND '+obj+'.journal_id IN (%s)' % ','.join(map(str, context['journal_ids']))
|
||||
|
||||
|
|
|
@ -58,10 +58,11 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header):
|
|||
obj_partner = self.pool.get('res.partner')
|
||||
self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
|
||||
ctx2 = data['form'].get('used_context',{}).copy()
|
||||
ctx2.update({'initial_bal': True})
|
||||
self.initial_balance = data['form'].get('initial_balance', True)
|
||||
if self.initial_balance:
|
||||
ctx2.update({'initial_bal': True})
|
||||
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
|
||||
self.reconcil = data['form'].get('reconcil', True)
|
||||
self.initial_balance = data['form'].get('initial_balance', True)
|
||||
self.result_selection = data['form'].get('result_selection', 'customer')
|
||||
self.amount_currency = data['form'].get('amount_currency', False)
|
||||
self.target_move = data['form'].get('target_move', 'all')
|
||||
|
|
|
@ -39,9 +39,22 @@ class account_partner_ledger(osv.osv_memory):
|
|||
}
|
||||
_defaults = {
|
||||
'reconcil': True,
|
||||
'initial_balance': True,
|
||||
'initial_balance': False,
|
||||
'page_split': False,
|
||||
}
|
||||
def onchange_initial_balance(self, cr, uid, ids, initial_balance=False, reconcil=False, context=None):
|
||||
res = {'value': {}}
|
||||
if initial_balance:
|
||||
res['value'] = {
|
||||
'reconcil': False
|
||||
}
|
||||
return res
|
||||
|
||||
def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
|
||||
res = super(account_partner_ledger, self).onchange_filter(cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id, context=context)
|
||||
if filter == 'filter_no':
|
||||
res['value'].update({'initial_balance': False})
|
||||
return res
|
||||
|
||||
def _print_report(self, cr, uid, ids, data, context=None):
|
||||
if context is None:
|
||||
|
|
|
@ -15,12 +15,15 @@
|
|||
</xpath>
|
||||
<xpath expr="//field[@name='target_move']" position="after">
|
||||
<field name="result_selection"/>
|
||||
<field name="initial_balance"/>
|
||||
<field name="reconcil"/>
|
||||
<field name="initial_balance" attrs="{'readonly':[('filter', '=', 'filter_no')]}" on_change="onchange_initial_balance(initial_balance, reconcil)"/>
|
||||
<field name="reconcil" attrs="{'readonly':[('initial_balance', '=', True)]}" on_change="onchange_initial_balance(initial_balance, reconcil)"/>
|
||||
<field name="amount_currency"/>
|
||||
<field name="page_split"/>
|
||||
<newline/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='filter']" position="replace">
|
||||
<field name="filter" strint="replaced" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue