Importing csv file with children of existing parent gives error

Bug #1091184 reported by Ronald Portier (Therp)
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Confirmed
Medium
OpenERP's Framework R&D
Therp Backports (Deprecated)
Fix Released
Medium
Ronald Portier (Therp)
Server-6.1
Fix Released
Undecided
Unassigned
Server-7.0
New
Undecided
Unassigned

Bug Description

I have a csv files with product categories, that should be linked to the main category (the one with xml ID cat0). I try to import the csv file trough the user interface. This results in in error, saying that None can not be linked to an int.

The csv file looks like this:

id,parent_id/id,name
cat_bevestiging,product.cat0,Bevestiging
cat_elektra,product.cat0,Elektra
cat_gereedschap,product.cat0,Gereedschap

The import creates the first record (committed to the database), then returns an error, and the rest of the import fails.

So apart from the original error, there is the error that a partial import is committed.

The error occurs during computation of the parent_left, parent_right values. Because the main category, does not have parent_left or parent_right set in the database. (I think this is an error too, by the way).

The import error can be easily solved by patching one line in orm.py.

Tags: csv import parent

Related branches

Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

Improved patch, with only the changes necesarry

Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :
Changed in openobject-server:
status: New → Incomplete
Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

Hello Jignesh,

As far as I can see, your import links to subcategories of the main category.

But the error specifically occurs when there are no categories under the main category yet. That is when the parent_left of the main (and only) existing category will be NULL in the database, and None when retrieved through the cr cursor.

So to reproduce: start with an empty database and make sure parent left and right have not been set:

test_db=# select id, parent_left, parent_right, name, parent_id from product_category:

 id | parent_left | parent_right | name | parent_id
----+-------------+--------------+--------------+-----------
  1 | | | All products |
(1 row)

Kind regards,

Ronald

Changed in openobject-server:
status: Incomplete → New
Changed in therp-backports:
status: New → Fix Committed
importance: Undecided → Medium
assignee: nobody → Ronald Portier (Therp) (rportier1962)
milestone: none → 6.1-maintenance
Changed in therp-backports:
status: Fix Committed → Fix Released
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
importance: Low → Medium
Lara (Therp) (lfreeke)
Changed in therp-backports:
milestone: 6.1-maintenance → 7.0-maintenance
Lara (Therp) (lfreeke)
Changed in therp-backports:
milestone: 7.0-maintenance → none
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.