Boubaker
Boubaker

Reputation: 429

OpenERP Function python

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

like the photo enter image description here

enter image description here

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

Answers (1)

Prakash Kumar
Prakash Kumar

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

Related Questions