[FIX] account: statement reconciliaiton improved

bzr revid: qdp-launchpad@tinyerp.com-20101126151446-72q1m6qc9efqqga0
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-11-26 16:14:46 +01:00
parent 56bbbfcd62
commit 382f6fc8c5
2 changed files with 10 additions and 7 deletions

View File

@ -149,6 +149,7 @@ class account_bank_statement(osv.osv):
\n* And after getting confirmation from the bank it will be in \'Confirmed\' state.'),
'currency': fields.function(_currency, method=True, string='Currency',
type='many2one', relation='res.currency'),
'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'),
}
_defaults = {
@ -369,14 +370,15 @@ class account_bank_statement(osv.osv):
done.append(st.id)
return self.write(cr, uid, done, {'state':'draft'}, context=context)
def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
cursor.execute('SELECT balance_end_real \
def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
cr.execute('SELECT balance_end_real \
FROM account_bank_statement \
WHERE journal_id = %s AND NOT state = %s \
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
res = cursor.fetchone()
res = cr.fetchone()
balance_start = res and res[0] or 0.0
return {'value': {'balance_start': balance_start}}
account_id = self.pool.get('account.journal').read(cr, uid, journal_id, ['default_debit_account_id'], context=context)['default_debit_account_id']
return {'value': {'balance_start': balance_start, 'account_id': account_id}}
def unlink(self, cr, uid, ids, context=None):
stat = self.read(cr, uid, ids, ['state'])
@ -454,4 +456,4 @@ class account_bank_statement_line(osv.osv):
account_bank_statement_line()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -609,16 +609,17 @@
<group col="7" colspan="4">
<field name="name" select="1"/>
<field name="date" select="1" on_change="onchange_date(date)"/>
<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" select="1"/>
<field name="journal_id" domain="[('type', '=', 'bank')]" on_change="onchange_journal_id(journal_id)" widget="selection"/>
<newline/>
<field name="period_id"/>
<field name="balance_start"/>
<field name="balance_end_real"/>
<field name="currency" invisible="1"/>
<field name="account_id" invisible="1"/>
</group>
<notebook colspan="4">
<page string="Journal Entries">
<field colspan="4" name="move_line_ids" nolabel="1" widget="many2many" domain="[('statement_id', '=', False)]">
<field colspan="4" name="move_line_ids" nolabel="1" widget="many2many" domain="[('account_id','=',account_id),('statement_id', '=', False)]">
<tree string="Statement lines">
<field name="date"/>
<field name="period_id"/>