Reputation: 429
I want to do on the writing process. I have created e new field in the tree view '' Total Caisse''. I want to show the same total existing ' Montant' , but if journal id ''Journal des achats " Total negative shows
For example
this true function
def _amount_compute(self, cr, uid, ids, name, args, context, where =''):
if not ids: return {}
cr.execute( 'SELECT move_id, SUM(debit) '\
'FROM account_move_line '\
'WHERE move_id IN %s '\
'GROUP BY move_id', (tuple(ids),))
result = dict(cr.fetchall())
for id in ids:
result.setdefault(id, 0.0)
return result
this my function
def _caisse _compute(self, cr, uid, ids, name, args, context, where =''):
if not ids: return {}
cr.execute( 'SELECT journal_id,SUM(debit) *-1 '\
'FROM account_move_line '\
'WHERE journal_id =2 '\
'GROUP BY journal_id', (tuple(ids),))
result = dict(cr.fetchall())
for id in ids:
result.setdefault(id, 0.0)
return result
Upvotes: 0
Views: 138
Reputation: 2594
Your query is still unclear for us.
Regrading:if journal id ''Journal des achats " Total negative shows
Correct your query by replacing SELECT journal_id,SUM(debit) *-1 '
with SELECT journal_id,SUM(debit)'
Like:
cr.execute( 'SELECT journal_id,SUM(debit)'\
'FROM account_move_line '\
'WHERE journal_id =2 '\
'GROUP BY journal_id', (tuple(ids),))
I hope it may help in your case.
Upvotes: 1