Skip to content

Commit

Permalink
[FIX]account_payment_group:order lines by date maturity
Browse files Browse the repository at this point in the history
Ticket: 57884
  • Loading branch information
pablohmontenegro committed Dec 7, 2022
1 parent f483bec commit c3c19af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion account_payment_group/models/account_payment_group.py
Expand Up @@ -363,7 +363,13 @@ def _compute_matched_move_line_ids(self):
"""
for rec in self:
payment_lines = rec.payment_ids.mapped('move_line_ids').filtered(lambda x: x.account_internal_type in ['receivable', 'payable'])
rec.matched_move_line_ids = (payment_lines.mapped('matched_debit_ids.debit_move_id').sorted(key=lambda x: x.date_maturity) | payment_lines.mapped('matched_credit_ids.credit_move_id')).sorted(key=lambda x: x.date_maturity) - payment_lines
debit_moves = payment_lines.mapped('matched_debit_ids.debit_move_id')
credit_moves = payment_lines.mapped('matched_credit_ids.credit_move_id')
debit_lines_sorted = debit_moves.filtered(lambda x: x.date_maturity != False).sorted(key=lambda x: x.date_maturity)
credit_lines_sorted = credit_moves.filtered(lambda x: x.date_maturity != False).sorted(key=lambda x: x.date_maturity)
debit_lines_without_date_maturity = debit_moves - debit_lines_sorted
credit_lines_without_date_maturity = credit_moves - credit_lines_sorted
rec.matched_move_line_ids = ((debit_lines_sorted + debit_lines_without_date_maturity) | (credit_lines_sorted + credit_lines_without_date_maturity)) - payment_lines

@api.depends('payment_ids.move_line_ids')
def _compute_move_lines(self):
Expand Down

0 comments on commit c3c19af

Please sign in to comment.