OpenERP 函数 python

OpenERP Function python

我想做的就写程序。我在树状视图 '' Total Caisse'' 中创建了一个新字段。我想显示相同的现有总数 ' Montant' ,但是如果期刊 ID ''Journal des achats " 总负数显示

例如

喜欢照片

这个真函数

 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

这是我的功能

    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 

我们仍然不清楚您的查询。

重新评分:if journal id ''Journal des achats " 负面显示总数

更正您的查询,将 SELECT journal_id,SUM(debit) *-1 ' 替换为 SELECT journal_id,SUM(debit)' 喜欢:

 cr.execute( 'SELECT journal_id,SUM(debit)'\
                'FROM account_move_line '\
                'WHERE journal_id =2 '\
                'GROUP BY journal_id', (tuple(ids),)) 

希望对您有所帮助。