Importing csv file with children of existing parent gives error
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_
cat_bevestiging
cat_elektra,
cat_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
- Stefan Rijnhart (Opener) (community): Approve on 2012-12-17
-
Diff: 12 lines (+1/-1)1 file modifiedopenerp/osv/orm.py (+1/-1)
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 |
Changed in therp-backports: | |
milestone: | 6.1-maintenance → 7.0-maintenance |
Changed in therp-backports: | |
milestone: | 7.0-maintenance → none |
Improved patch, with only the changes necesarry