Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
3410 Vizualizări

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

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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.


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
iun. 16
3482
2
nov. 23
3119
7
apr. 21
20491
1
oct. 20
4866
2
nov. 16
4216