Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
3372 Vistas

I need to get the total credit amount on all unreconciled entries and display it on a smart button. 

def _compute_refund_balance(self):
    for partner in self:
        moveline_obj = self.pool.get('account.move.line')
        movelines = moveline_obj.search_read(self._cr, self._uid, [('partner_id', '=', partner.id)], ['id', 'credit', 'debit'])
        partner.compute_refund_balance = sum((line['credit']-line['debit']) for line in movelines)    ​            ​


I need something to add inside the function. I have tried adding ('unreconciled','=', True) but still no luck.

Thank you

 ​         ​     ​     ​     ​         ​     ​         ​     ​         ​     ​     ​     ​         ​     ​

Avatar
Descartar
Autor Mejor respuesta

Is this how the system determine the unreconciled ones to the other? In the xml part it is filtered like this `search_default_unreconciled`. I have tried to do the below code but still gets more entries than expected, I tried to check within the db, I have about 135 move line for a certain partner and the unreconciled move line in the system are just 3 entries.


UPDATE:

I already fixed this by filtering the move lines by its account_account.type, all unreconciled entries are from either 'receivable' or 'payable' type of account


movelines = moveline_obj.search_read(self._cr, self._uid, ['&',('partner_id','=',partner.id),'|',('account_id.type','=','receivable'),('account_id.type','=','payable')],['id','credit','debit','account_id'])


Thanks

Avatar
Descartar
Mejor respuesta

You can check the move line with the reconcile _id field. if it's set then it should be reconciled. so change your search by

movelines = moveline_obj.search_read(self._cr, self._uid, [('partner_id', '=', partner.id), ('reconcile_id', '!=', False)], ['id', 'credit', 'debit'])

This is the correct way system checking the moves are reconciled or not like eg:

SELECT count(*) FROM account_move_line WHERE reconcile_id IS NULL AND id IN (xxx)
and we are comparing the boolean of result to know whether the move is reconciled or not.

If you need to know the partial reconciled entries then check the field reconcile_partial_id. If the field has value means the move is partially reconciled.


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
jun 16
3466
2
nov 23
3044
7
abr 21
20364
1
oct 20
4798
2
nov 16
4166