Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3421 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
giu 16
3491
2
nov 23
3135
7
apr 21
20506
1
ott 20
4877
2
nov 16
4226