Credit note on an invoice with allocated advances fails: "Rows: 1 in Advance Payments section are invalid"
Information about bug
Steps
Sales Order → Payment Entry against the order → Sales Invoice from the order with the advance allocated (Allocate Advances Automatically) → submit → Create > Return / Credit Note → Save.
Actual: "Rows: 1 in Advance Payments section are invalid. Reference Name should point to a valid Payment Entry or Journal Entry."
Cause
make_return_doc has no table map for advances, so get_mapped_doc copies the table and blanks the no_copy reference_type / reference_name / allocated_amount. The return also inherits allocate_advances_automatically, so once the rows are dropped, set_advances re-pulls any still-open order advance with a negative allocation.
Fix on my fork: (https://github.com/maasanto/erpnext/commit/db20f6b084).
Module
accounts
Version
develop
Installation method
None
Relevant log output / Stack trace / Full Error Message.
Source: frappe/erpnext