Consolidated credit notes linked to their invoice
Credit notes with lines from several sales orders never got reversed_entry_id. Localizations such as TicketBAI need that link to report the refund.
Credit notes with lines from several sales orders never got reversed_entry_id. Localizations such as TicketBAI need that link to report the refund.
| Branch | Pull request | Commit |
|---|---|---|
| 18.0 | odoo/odoo#288320 ↗ | 9b6aa32f4d ↗ |
| 19.0 | odoo/odoo#291159 ↗ | 7e6b005958 ↗ |
| 20.0 | odoo/odoo#291215 ↗ | 86707bc0a6 ↗ |
[FIX] account: link credit note to consolidated source invoice When a credit note (out_refund) consolidates sale lines coming from several orders, _set_reversed_entry fails to set reversed_entry_id. The check 'credit_note.invoice_line_ids.sale_line_ids in inv.invoice_line_ids.sale_line_ids' relies on recordset.__contains__, which requires the left operand to be a singleton and otherwise returns False. As a result reversed_entry_id is never set when the credit note carries lines from more than one order, even though it reverses a single consolidated invoice. Localizations such as TicketBAI rely on reversed_entry_id to build the refunded document reference and reject the refund otherwise with "Cannot post a reversal document while the source document has not been posted". Use the <= subset operator instead, which behaves correctly for singleton and multi-record sets alike. MT-15939