Skip to Content
Menu
This question has been flagged
2 Replies
2649 Views

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
Discard
Author Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
0
Jun 16
2787
2
Nov 23
1210
7
Apr 21
18378
1
Oct 20
3359
2
Nov 16
2916