[IMP]: account: Instead of dummy char fields, added new fields to compute un realized gain and loss, improvement in view

bzr revid: rpa@tinyerp.com-20111024102011-mwbwf707847onw7p
This commit is contained in:
Rucha (Open ERP) 2011-10-24 15:50:11 +05:30
parent 8eb357d693
commit bc7351bbd1
2 changed files with 9 additions and 9 deletions

View File

@ -243,7 +243,8 @@ class account_account(osv.osv):
'balance': "COALESCE(SUM(l.debit),0) " \
"- COALESCE(SUM(l.credit), 0) as balance",
'debit': "COALESCE(SUM(l.debit), 0) as debit",
'credit': "COALESCE(SUM(l.credit), 0) as credit"
'credit': "COALESCE(SUM(l.credit), 0) as credit",
'foreign_balance': "COALESCE(SUM(l.amount_currency), 0) as foreign_balance",
}
#get all the necessary accounts
children_and_consolidated = self._get_children_and_consol(cr, uid, ids, context=context)
@ -270,7 +271,7 @@ class account_account(osv.osv):
# ON l.account_id = tmp.id
# or make _get_children_and_consol return a query and join on that
request = ("SELECT l.account_id as id, " +\
', '.join(map(mapping.__getitem__, field_names)) +
', '.join(map(mapping.__getitem__, mapping.keys())) +
" FROM account_move_line l" \
" WHERE l.account_id IN %s " \
+ filters +
@ -418,13 +419,11 @@ class account_account(osv.osv):
'balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), string='Balance', multi='balance'),
'credit': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Credit', multi='balance'),
'debit': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
# 'foreign_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
'foreign_balance': fields.char('Foreign Balance', size=10),
'adjusted_balance': fields.char('Adjusted Balance', size=10),
'gain_loss_unrealized_balance':fields.char('Unrealized Gain Loss Balance', size=10),
# 'adjusted_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
# 'gain_loss_unrealized_balance': fields.function(__compute, fnct_inv=_set_credit_debit, digits_compute=dp.get_precision('Account'), string='Debit', multi='balance'),
'foreign_balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), string='Foreign Balance', multi='balance'),
'adjusted_balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), string='Adjusted Balance', multi='balance'),
'gain_loss_unrealized': fields.function(__compute, digits_compute=dp.get_precision('Account'), string='Unrealized Gains & Losses', multi='balance'),
'reconcile': fields.boolean('Allow Reconciliation', help="Check this box if this account allows reconciliation of journal items."),
'exchange_rate': fields.related('currency_id', 'rate', type='float', string='Exchange Rate'),
'shortcut': fields.char('Shortcut', size=12),
'tax_ids': fields.many2many('account.tax', 'account_account_tax_default_rel',
'account_id', 'tax_id', 'Default Taxes'),

View File

@ -304,10 +304,11 @@
<field name="code"/>
<field name="name"/>
<field name="currency_id"/>
<field name="exchange_rate"/>
<field name="foreign_balance"/>
<field name="adjusted_balance"/>
<field name="balance"/>
<field name="gain_loss_unrealized_balance"/>
<field name="gain_loss_unrealized"/>
</tree>
</field>
</record>