Replace party and credit invoice

Hi there,
I just faced an edge case in replacing parties and it’s not clear to me how to solve it in a clean way.

  • Crea te a invoice 1 for party A
  • Replace party A by party B
  • Try to credit invoice 1 and it returns domains errors due to inactive party, addresses, identifiers, lines etc…

How it’s supposed to credit this invoice? My two approximation on how to solve are:

  • Creating a party A.1 and generating manually a credit invoice for invoice 1? Later replace party A.1 by party B.
  • Undo all the work of replace party in the database, (I need to check all the fields_to_replace of all my installed modules), credit the invoice, and replace party again.

Neither of those solutions are clean/simple for me. Any suggestions?

Could you post exactly the domain errors that you have?
It is strange to have a domain error due to inactive records as (IIRC) we do not validate that any record should be active in order to be used on invoices.

So crediting it should not raise any error.

The value for field “Party Tax Identifier” in “Invoice” is not valid according to its domain.

It’s not for inactive, it’s because the old identifier of A is in the invoice, but the invoice 1 have the new party B, so on credit the new invoice is for party B, but the identifier is pointing to party=A.

I think you are hit by: Issue 10567: Move party_identifier with the PartyReplace wizard - Tryton issue tracker