Hi,

I'm trying to replace the built-in delete behavior in crud.update
(deletable=True) with a boolean active field instead, in order to NOT
do a hard-delete of any records but instead a soft-delete via the
active flag.

I'm also using onaccept=crud.archive.

I successfully manage to cancel the delete operation (currently in all
cases for testing purposes) via the following just before the
crud.update:

   if request.vars: del request.vars.delete_this_record

But when the crud.update is executed (with crud.archive) and the
delete checkbox is on, I get the following error:

<class 'psycopg2.IntegrityError'>(insert or update on table
"entity_archive" violates foreign key constraint
"entity_archive_current_record_fkey"
DETAIL:  Key (current_record)=(6) is not present in table "entity".)

Note that the record is NOT deleted (as expected), and therefore I
don't understand why crud.archive is complaining about it.

Also note that crud.update (with crud.archive) works ok when the
delete checkbox is off.

I've checked request.vars and I don't see any problems.

Can you please help?.

Thanks,

   Carlos

Reply via email to