Required fields have the set NOT NULL attribute. This cannot work together
with ON DELETE SET NULL behaviour for their referenced records. The
safest default seems to be ON DELETE RESTRICT.
Example: account.invoice:partner_id, which has to restrict deleting a
partner when there is any invoices linked to him/her.
This merely improves the SQL messages, from:
IntegrityError: null value in column "partner_id" violates not-null constraint
CONTEXT: SQL statement "UPDATE ONLY "public"."account_invoice" SET "partner_id" = NULL
WHERE $1 OPERATOR(pg_catalog.=) "partner_id""
to:
IntegrityError: update or delete on table "res_partner" violates foreign key
constraint "account_invoice_partner_id_fkey" on table "account_invoice"
DETAIL: Key (id)=(7) is still referenced from table "account_invoice".