← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 698354] Re: [6.0rc2] csv import data mangled (with solution)

 

** Changed in: openobject-server
   Importance: Undecided => Low

** Changed in: openobject-server
       Status: New => Confirmed

** Changed in: openobject-server
     Assignee: (unassigned) => OpenERP's Framework R&D (openerp-dev-framework)

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

Title:
  [6.0rc2] csv import data mangled (with solution)

Status in OpenObject Server:
  Confirmed

Bug description:
  Many2one fields with name are getting related to the wrong objects with hilarious/disastrous results.
e.g. my res.users.csv specified menu_id of 'Menu' but got 'Board Create Menu' resulting in complete lockout :-(

The problem is name_search() is building this query:

   SELECT "ir_actions".id FROM "ir_actions" WHERE (ir_actions.name ilike E'%Menu%') ORDER BY name limit 100

The use of 'ilike' means that if there is more than one action with 'Menu' in the name then it is pot-luck which one you get and more than likely chaos will ensue.
The match must be exact, so the operator must be specified as '=', thus:

=== modified file 'bin/osv/orm.py'
--- bin/osv/orm.py	2010-12-29 18:25:09 +0000
+++ bin/osv/orm.py	2011-01-06 22:00:15 +0000
@@ -726,7 +726,7 @@
                 id = ir_model_data[0]['res_id']
             else:
                 obj_model = self.pool.get(model_name)
-                ids = obj_model.name_search(cr, uid, id)
+                ids = obj_model.name_search(cr, uid, id, operator='=')
                 if not ids:
                     raise ValueError('No record found for %s' % (id,))
                 id = ids[0][0]





References