References (fields.reference) if deleted, should affect on target objects too.

Bug #406357 reported by Ferdinand
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
Jay Vora (Serpent Consulting Services)

Bug Description

branch-server 1735
branch-addons 2324

very likely to be data or GTK r959 dependant
koo r890 switches from list to form without problems

had to remove the project name_get function from project_timesheet.py to continue working.

Environment_Information :
PlatForm : linux2
Operating System : posix
Operating System Version : [GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]]
Operating System Locale : en_US
Python Version : 2.5.2
OpenERP-Client Version : 5.0.1
Last revision Details :

Traceback (most recent call last):
  File "/home/terp/OpenERP/branch/server/5.0/bin/netsvc.py", line 231, in dispatch
    result = LocalService(service_name)(method, *params)
  File "/home/terp/OpenERP/branch/server/5.0/bin/netsvc.py", line 74, in __call__
    return getattr(self, method)(*params)
  File "/home/terp/OpenERP/openobject-server/bin/addons/base_module_record/base_module_record.py", line 37, in execute
    res = fnct(*args, **argv)
  File "/home/terp/OpenERP/branch/server/5.0/bin/service/web_services.py", line 496, in execute
    res = service.execute(db, uid, object, method, *args)
  File "/data/downloads/bzr/branch/server/5.0/bin/osv/osv.py", line 59, in wrapper
  File "/data/downloads/bzr/branch/server/5.0/bin/osv/osv.py", line 119, in execute
  File "/data/downloads/bzr/branch/server/5.0/bin/osv/osv.py", line 111, in execute_cr
  File "/home/terp/OpenERP/openobject-server/bin/addons/project_timesheet/project_timesheet.py", line 119, in name_get
    name = "[%s] %s" % (project.category_id and project.category_id.code or '?', project.name)
  File "/home/terp/OpenERP/branch/server/5.0/bin/osv/orm.py", line 216, in __getattr__
    return self[name]
  File "/home/terp/OpenERP/branch/server/5.0/bin/osv/orm.py", line 212, in __getitem__
    return self._data[self._id][name]
KeyError: 'category_id'

Related branches

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Ferdinand,
It seems like you have deleted the project and you try to refresh the view.

Would you please tell us which modules have you installed?and the exact flow through which you met to the error?

Thanks.

Changed in openobject-client:
status: New → Incomplete
Revision history for this message
Ferdinand (office-chricar) wrote :

this a client installation not my development system
branch-server 1735
branch-addons 2324

nobody was supposed to delete the product, but the product manager can do this,
that's why I'd like to have set up a proper audit trail - shows
* what
* who
* when
and it should run on most "master" tables like account, project, partner ...

is it possible to find out with a script where such problems might occur ?
i.e where the database model is less strict (and must be) than the Object Model?

IMHO the system should not allow to delete referenced (and generate constraints as below but this is a technical problem because the lines may also have records without product_id.)

account_analytic_line
 "account_analytic_line_product_id_fkey" FOREIGN KEY (product_id) REFERENCES product_product(id) ON DELETE SET NULL

and product_id in working hours is mandatory

affects: openobject-client → openobject-server
Changed in openobject-server:
status: Incomplete → New
Changed in openobject-server:
status: New → Confirmed
assignee: nobody → gpa(tiny) (gpa-openerp)
summary: - crm cases opening form error
+ References (fields.reference) should not be allowed to be deleted
Changed in openobject-server:
importance: Undecided → Wishlist
importance: Wishlist → Medium
assignee: gpa(tiny) (gpa-openerp) → nobody
Changed in openobject-server:
assignee: nobody → Jay (Open ERP) (jvo-openerp)
Changed in openobject-server:
status: Confirmed → In Progress
summary: - References (fields.reference) should not be allowed to be deleted
+ References (fields.reference) if deleted, should affect on target
+ objects too.
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Ferdinand,

Would you please try and check with this patch?

Thanks.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

The steps to reproduce the error:
1. Install project_timesheet and crm.

2. Create a case, on one of the reference fields on the case,assign one project.

3. Delete the same project entry from DB or unlink from form.

4. Try to open the case again.

5. Error appears.

Thank you.

Revision history for this message
Ferdinand (office-chricar) wrote :

Hmm!

Now it deletes the reference in CRM - case
IMHO this is technically ok if the field is not mandatory

Anyhow I see a big danger to allow deleting references quietly.

Example Timesheet
Enter a line with analytic account - work time is 2 hours
somebody deletes the analytic account
the time encoding line is deleted - the employee has no chance to prove his working time if someone can delete his encoding by removing the analytic account - a "wrong" analytic account does not mean he didn't work.

Actually this absolutely is inadmissible !!!

IMHO this needs to be redesigned - ideas

* display the referencing resources before deletion
** due to the flexible construct of references these can be made from many objects and the one who has the right to delete may not know all possibilities
** how to handle access rights ??? - just show the number of records if the deleting user has no read access
* do not allow deleting referenced resources - except for admin and/or users with special roles.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Ferdinand,

We absolutely agree with your point of view, its really an enhancement.

However, The admin user has to be quite careful while deleting any resource.

My humble request will stay as that you create a blueprint for this issue,we will plan for the best solution.

For the current post,It has been fixed by revision 1874 <email address hidden>.

Thank you.

Changed in openobject-server:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.