Wednesday, March 20, 2013

Workaround for Kettle Steps to work with OpenERP 7

The Kettle OpenERP Output Step currently doesn't work with v7.

The problem seems to be that OpenERP v7 requires the ID to exist if specified, and the Output Step sends an ID 0 for new records. This does not work with the v7 ORM load method:

Failed to commit batch:
Line 1 : Unknown database identifier '0'
Caused by: com.debortoliwines.openerp.api.OpeneERPApiException: Line 1 : Unknown database identifier '0'

A workaround is to modify the BaseModel object, _convert_records function, so it that a zero ID is considered equivalent to an empty id. Here is the diff of the fix if you want to apply it yourself:

--- openerp/osv/     2013-03-20 22:21:17.892445229 +1100
+++ openerp/osv/  2013-03-20 22:05:12.474594534 +1100
@@ -1499,7 +1499,9 @@ class BaseModel(object):
                 except ValueError:
                     # in case of overridden id column
                     dbid = record['.id']
-                if not, uid, [('id', '=', dbid)], context=context):
+                if dbid == 0:
+                    dbid = False
+                elif not, uid, [('id', '=', dbid)], context=context):

A branch with the change is also available in Launchpad.

No comments:

Post a Comment