Merge lp:~openerp-dev/openobject-server/6.0-opw-50841-nep into lp:openobject-server/6.0

Proposed by Nehal Panchal (OpenERP)
Status: Rejected
Rejected by: Olivier Laurent (Open ERP)
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-50841-nep
Merge into: lp:openobject-server/6.0
Diff against target: 12 lines (+1/-1)
1 file modified
bin/addons/base/ir/ir_model.py (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-50841-nep
Reviewer Review Type Date Requested Status
Olivier Laurent (Open ERP) (community) Disapprove
Naresh(OpenERP) (community) Approve
Review via email: mp+86890@code.launchpad.net

Description of the change

Hello,

If we give same XML Identifier for the different models, it will override the data of same XML Identifier instead of creating new data in ir_model_data object.i.e
It was possible to declare the same id for different model in the same module, and this cause errors if the programmer don't see without any warning
This fixes the issue.

Thanks.

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) :
review: Approve
Revision history for this message
Olivier Laurent (Open ERP) (olt) wrote :

The current constraint 'ir_model_data_module_name_uniq' on ir_model_data table is already preventing from inserting 2 records with the same name and module, so you cannot insert a record with the same xml_id ('name' field) within the same module.

Example:

if you already have a record: name: 'next_id_2', module: 'base', model: 'ir.ui.menu'

you will not be able to insert this record: 'next_id_2', module: 'base', model: 'sale.order'

because the name and module are the same as another record.

Your constraint on (name, model, module) is less restrictive than before. So if we change the current constraint (name, module) to the new one (name, model, module), we will be able to insert records having the same xml_id for the same module which will raise the problems defined in the issue.

review: Disapprove

Unmerged revisions

3559. By Nehal Panchal (OpenERP)

[FIX] base : Improve sql constraints for allowing same XML Identifier for the different models

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/base/ir/ir_model.py'
2--- bin/addons/base/ir/ir_model.py 2011-09-29 05:09:38 +0000
3+++ bin/addons/base/ir/ir_model.py 2011-12-26 10:35:28 +0000
4@@ -575,7 +575,7 @@
5 'module': ''
6 }
7 _sql_constraints = [
8- ('module_name_uniq', 'unique(name, module)', 'You cannot have multiple records with the same id for the same module !'),
9+ ('module_name_uniq', 'unique(name, model, module)', 'You cannot have multiple records with the same id for the same object of the same module !'),
10 ]
11
12 def __init__(self, pool, cr):