After a duplicate Party is deleted, I get "You try to read records that don't exist anymore. (Document type:"

I replaced a party by another with the wizard. Then when accessing to Invoices, I get the message “You try to read records that don’t exist anymore. (Document type:” and invoices are blank (no name, no content in list view).
How to repair this?

Did you check the value of the party column in the database? Does it exist in the party_party table? Is there a correct foreign key defined on this column?

Seems correct… I forgot to add that I access to invoices related to the Party. So I think it cannot be the that’s not correct…
Despite the warning message, I can see each of the six invoices in detailed view. Each time I’m proposed to save the record (though I changed nothing). If I choose Save, I get the error “You can not modify invoice XXX because it is posted, paid or cancelled.”

Was it an error to delete the duplicate Party once replaced by the to-be-kept Party?

I couldn’t solve this. For two Parties that were created twice, I used the Replace wizard to have all existing docs use only one of the duplicated Parties, then I deleted the one without docs. But Invoices attached to the unique remaining Party have a strange behaviour: they cannot be opened, nor displayed, either asking for Save changes (yes answer yields You cannot change posted invoices) or complaining for records non existing.
Any solution to repair this?
Is this a known bug for the Replace party wizard?

This sounds like a field that has no value (or a invalid value) and the client detects this as modified.
This may be a bug on some module that does not set the value for a field that depends on party.

Do you have the steps to reproduce on a fresh database? If so please open a bug.

I couldn’t reproduce it on demo. Seems to be linked to a related field, maybe is it anoter module, as party_relationship or party_history. Examining db by hand showed no missing record in fkeys…
Here is the traceback when reading the invoices:

Traceback (most recent call last):
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/protocols/", line 176, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/", line 859, in read
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/", line 830, in read
    getter_results = field.get(ids, cls, field_list, values=result)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/fields/", line 103, in get
    return dict((name, call(name)) for name in names)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/fields/", line 103, in <genexpr>
    return dict((name, call(name)) for name in names)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/fields/", line 98, in call
    return dict((, method(r, name)) for r in records)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/fields/", line 98, in <genexpr>
    return dict((, method(r, name)) for r in records)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/modules/party/", line 204, in get_rec_name
    if not
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/fields/", line 298, in __get__
    return inst.__getattr__(
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/", line 1435, in __getattr__
    read_data =, list(ffields.keys()))
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/model/", line 759, in read
    cls.raise_user_error('read_error', cls.__name__)
  File "/Users/jcm/Sites/_tryton/tryton5.0/.env/lib/python3.6/site-packages/trytond/", line 74, in raise_user_error
    raise UserError(error)
trytond.exceptions.UserError: Vous essayez de lire des enregistrements qui n'existent plus.
(Type du document: - 

Do you have an idea of the field I should examine?

From the traceback I see that the problem is reading the name field when computing the rec_name.

As this comes from fields related, it seems that the problem is that invoice is reading the party rec_name of a party that do not exists.

Could you share the steps to reproduce the traceback?

Two identical parties, with invoices on each one. One replaced by another with the Party Replace Wizard. Then the one replaced deleted with the Party Delete Wizard. Show the unique remaining party. Choose Related invoices.

Searching invoices by ID from the client, I noticed that the error occurs only on the invoices that were entered with the now deleted party.

I suspect it is because of the module account_invoice_history. It set the datetime to read the party at the numbered date. But if the replacing party is newer than the numbered date, trying the read for example the rec_name will fail at a date before its creation.
A possible solution would be to update the numbered_at to the creation date of the new party if it is after. Maybe there are other better solutions which allow to keep the real history.

I cannot find numbered_at anywhere in the code. Could you please point me to the place it is defined? Or maybe is it something added after 5.0?

It is defined in account_invoice_history but on 5.0 series it is called open_date.

Thks a sql update solved it.

In party module, when replacing, the replacing could take the create_date value of the replaced maybe.

I filled Issue 9300: Access error for invoice with replaced party - Tryton issue tracker to get a proper solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.