← Back to team overview

openerp-india team mailing list archive

[Bug 1102612] Re: [Trunk/7.0]Journals can not be deleted, even when they have no entries

 

I'd also say this approach of trying to cover every individual case of a
user action violating with a special error message is a bad idea. See
this earlier bug I reported:

https://bugs.launchpad.net/openobject-addons/+bug/1096439

The issue is that there are probably *thousands* of places where a user
could delete or modify something and violate a database constraint. If
you try to write code to handle each one individually, you will miss
some for sure. Worse, some of them will be wrong, as in that bug.

And, the code that has now been put everywhere will be more complicated
and hard to read, and it's just doing the same thing the database should
be doing anyway. Besides being pointless, it's inefficient. With the
proposed change, there must be an additional database query, and the
data must go through all the python code and the ORM. Why do all this
work, when the database will check it anyway? PostgreSQL, written in C,
without the network overhead, without all the ORM logic, will be at
least 100x faster.

A better approach would be to attempt the operation, and let the
database raise an error if there's a problem, then handle *that* error.
Or better, inform the database on ways to handle the problem itself,
like in this case, making the constraint ON DELETE CASCADE. That will be
much cleaner and faster.

-- 
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/1102612

Title:
  [Trunk/7.0]Journals can not be deleted, even when they have no entries

Status in OpenERP Addons (modules):
  Confirmed

Bug description:
  7.0 creates, as part of the default accounting setup, a "Bank" and a
  "Cash" journal. Attempting to delete either of these journals presents
  the cryptic error:

  Integrity Error

  The operation cannot be completed, probably due to the following:
  - deletion: you may be trying to delete a record while other records still reference it
  - creation/update: a mandatory field is not correctly set

  [object with reference: account.journal.cashbox.line -
  account.journal.cashbox.line]

  This is also just as relevant to any journal created by the user.

  There is indeed a table account.journal.cashbox.line that references
  the journal, but it's extra confusing to a user since no action was
  ever taken to associate this journal with a cashbox, and there does
  not appear to be any way to delete the offending
  account.journal.cashbox.line records through the UI that I have found.
  Deleting them directly from the database is of course possible, but
  probably not an acceptable workaround for typical users.

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


References