← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 733252] [NEW] osv/fields: required fields shall have ondelete="restrict" by default

 

Public bug reported:

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".

** Affects: openobject-server
     Importance: Undecided
     Assignee: xrg (xrg)
         Status: Fix Committed


** Tags: fields

** Changed in: openobject-server
       Status: New => In Progress

** Changed in: openobject-server
     Assignee: (unassigned) => xrg (xrg)

** Branch linked: lp:~openerp-dev/openobject-server/6.0-bug-733252-xrg

** Changed in: openobject-server
       Status: In Progress => Fix Committed

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/733252

Title:
  osv/fields: required fields shall have ondelete="restrict" by default

Status in OpenERP Server:
  Fix Committed

Bug description:
  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".



Follow ups

References