Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3379 Widoki

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

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Najlepsza odpowiedź

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.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
cze 16
3474
2
lis 23
3067
7
kwi 21
20410
1
paź 20
4813
2
lis 16
4180