Use the right currency to compute balance, debit/credit of accounts
This commit is contained in:
1 parent
eb5afa2fd1
commit
0c83b61930
3 files changed
+19
-4
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Use the right currency to compute balance, debit/credit of accounts
|
||||
|
||||
Version 1.2.0 - 2009-04-20
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
* Allow egg installation
|
||||
|
||||
+16
-4
@@ -133,16 +133,22 @@ class Account(ModelSQL, ModelView):
|
||||
line_query = line_obj.query_get(cursor, user, context=context)
|
||||
cursor.execute('SELECT a.id, ' \
|
||||
'SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))), ' \
|
||||
'l.currency ' \
|
||||
'c.currency ' \
|
||||
'FROM analytic_account_account a ' \
|
||||
'LEFT JOIN analytic_account_line l ' \
|
||||
'ON (a.id = l.account) ' \
|
||||
'LEFT JOIN account_move_line ml ' \
|
||||
'ON (ml.id = l.move_line) ' \
|
||||
'LEFT JOIN account_account aa ' \
|
||||
'ON (aa.id = ml.account) ' \
|
||||
'LEFT JOIN company_company c ' \
|
||||
'ON (c.id = aa.company) ' \
|
||||
'WHERE a.type != \'view\' ' \
|
||||
'AND a.id IN (' + \
|
||||
','.join(['%s' for x in all_ids]) + ') ' \
|
||||
'AND ' + line_query + ' ' \
|
||||
'AND a.active ' \
|
||||
'GROUP BY a.id, l.currency', all_ids)
|
||||
'GROUP BY a.id, c.currency', all_ids)
|
||||
account_sum = {}
|
||||
id2currency = {}
|
||||
for account_id, sum, currency_id in cursor.fetchall():
|
||||
@@ -196,16 +202,22 @@ class Account(ModelSQL, ModelView):
|
||||
line_query = line_obj.query_get(cursor, user, context=context)
|
||||
cursor.execute('SELECT a.id, ' \
|
||||
'SUM(COALESCE(l.' + name + ', 0)), ' \
|
||||
'l.currency ' \
|
||||
'c.currency ' \
|
||||
'FROM analytic_account_account a ' \
|
||||
'LEFT JOIN analytic_account_line l ' \
|
||||
'ON (a.id = l.account) ' \
|
||||
'LEFT JOIN account_move_line ml ' \
|
||||
'ON (ml.id = l.move_line) ' \
|
||||
'LEFT JOIN account_account aa ' \
|
||||
'ON (aa.id = ml.account) ' \
|
||||
'LEFT JOIN company_company c ' \
|
||||
'ON (c.id = aa.company) ' \
|
||||
'WHERE a.type != \'view\' ' \
|
||||
'AND a.id IN (' + \
|
||||
','.join(['%s' for x in ids]) + ') ' \
|
||||
'AND ' + line_query + ' ' \
|
||||
'AND a.active ' \
|
||||
'GROUP BY a.id, l.currency', ids)
|
||||
'GROUP BY a.id, c.currency', ids)
|
||||
|
||||
id2currency = {}
|
||||
for account_id, sum, currency_id in cursor.fetchall():
|
||||
|
||||
@@ -14,6 +14,7 @@ class Line(ModelSQL, ModelView):
|
||||
name = fields.Char('Name', required=True)
|
||||
debit = fields.Numeric('Debit', digits=(16, 2))
|
||||
credit = fields.Numeric('Credit', digits=(16, 2))
|
||||
#TODO wrong field as currency comes from move_line
|
||||
currency = fields.Many2One('currency.currency', 'Currency', required=True)
|
||||
account = fields.Many2One('analytic_account.account', 'Account',
|
||||
required=True, select=1, domain=[('type', '!=', 'view')])
|
||||
|
||||
Reference in new issue
Block a user