← Back to team overview

openerp-india team mailing list archive

[Bug 873092] Re: account_fiscal_position should have a foreing rules to cancel removal

 

After more investigation : according to one of my collegues, the
integrity mecanism in OpenERP that sometimes prevents you from deleting
an object (a product for example) works only when there is a _required_
field (many2one for example) pointing to this object.

In the case of fiscal position, there are many2one fields pointing to
fiscal positions from res.partner, sale.order, purchase.order and
account.invoice, but these many2one fields are never required. This
explains that you can delete a fiscal position even if it is used by
another object, an invoice for example.

Maybe someone has a better understanding of the integrity mecanism and
can add more technical info about it.

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Addons.
https://bugs.launchpad.net/bugs/873092

Title:
  account_fiscal_position should have a foreing rules to cancel removal

Status in OpenERP Addons (modules):
  Confirmed

Bug description:
  Dear all,

  This is OpenERP 6.03 with French accounting rules.

  While working on a new fiscal rule, I was able to delete an important rule, 
  which is for applying taxes in the European Union.

  I had nearly a heart attack!

  Fortunately, I had a PostgreSQL backup and could access the table structure using pgAdmin3.
  This is table account_fiscal_position. I used vim to import the missing line.

  Then I discovered that the taxes registered in the fiscal rule had
  been removed also.

  At PostgreSQL level, there should be a foreign rule to cancel removing
  a fiscal rule when it contains taxes.

  The table definition is:

  CREATE TABLE account_fiscal_position_account
  (
    id serial NOT NULL,
    create_uid integer,
    create_date timestamp without time zone,
    write_date timestamp without time zone,
    write_uid integer,
    position_id integer NOT NULL, -- Fiscal Position
    account_dest_id integer NOT NULL, -- Account Destination
    account_src_id integer NOT NULL, -- Account Source
    CONSTRAINT account_fiscal_position_account_pkey PRIMARY KEY (id ),
    CONSTRAINT account_fiscal_position_account_account_dest_id_fkey FOREIGN KEY (account_dest_id)
        REFERENCES account_account (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE SET NULL,
    CONSTRAINT account_fiscal_position_account_account_src_id_fkey FOREIGN KEY (account_src_id)
        REFERENCES account_account (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE SET NULL,
    CONSTRAINT account_fiscal_position_account_create_uid_fkey FOREIGN KEY (create_uid)
        REFERENCES res_users (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE SET NULL,
    CONSTRAINT account_fiscal_position_account_position_id_fkey FOREIGN KEY (position_id)
        REFERENCES account_fiscal_position (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE CASCADE,
    CONSTRAINT account_fiscal_position_account_write_uid_fkey FOREIGN KEY (write_uid)
        REFERENCES res_users (id) MATCH SIMPLE
        ON UPDATE NO ACTION ON DELETE SET NULL
  )
  WITH (
    OIDS=FALSE
  );

  I don't know OpenERP very well, but I guess it there should be an additional check to cancel any accidental removal.
  A fiscal rule with taxes ... should never be removed. A user should remove taxes one by one and then remove the fiscal rule.
  This way, there is little chance for accidental removal.

  Also, just for information, I had used this rule in 100s of entries.
  So maybe removing a fiscal rule being used ... should not be allowed in any cases, as it breaks the information system.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/873092/+subscriptions