Importing csv file with children of existing parent gives error

Bug #1091184 reported by Ronald Portier (Therp) on 2012-12-17
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)
Medium
Ronald Portier (Therp)
Server-6.1
Undecided
Unassigned
Server-7.0
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.

Related branches

Improved patch, with only the changes necesarry

Changed in openobject-server:
status: New → Incomplete

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
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) on 2013-01-23
Changed in therp-backports:
milestone: 6.1-maintenance → 7.0-maintenance
Lara (Therp) (lfreeke) on 2013-01-23
Changed in therp-backports:
milestone: 7.0-maintenance → none
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers