TypeError: node contents must be a string when using base_module_record

Bug #696176 reported by OpenBMS JSC
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Low
OpenERP R&D Addons Team 2

Bug Description

Use base_module_record to export customizations (related to account.) and got the following error

Environment Information :
System : Linux-2.6.32-27-generic-x86_64-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.1 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-27-generic
Operating System Version : #49-Ubuntu SMP Thu Dec 2 00:51:09 UTC 2010
Operating System Architecture : 64bit
Operating System Locale : vi_VN.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.0-rc1-1
Last revision No. & ID :1749 <email address hidden>
Traceback (most recent call last):
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/service/web_services.py", line 635, in dispatch
    res = fn(db, uid, *params)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/service/web_services.py", line 662, in exp_execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/service/web_services.py", line 644, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 177, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 153, in execute_cr
    return self.execute_cr(cr, uid, data, next_state, context)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 72, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/wizard/base_module_record_data.py", line 119, in _create_xml
    res_xml = mod.generate_xml(cr, uid)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 472, in generate_xml
    res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 388, in _generate_object_xml
    record,noupdate = self._create_record(cr, uid, doc, rec[2], rec[5], id)
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 215, in _create_record
    field.appendChild(doc.createTextNode(val))
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1611, in createTextNode
    raise TypeError, "node contents must be a string"
TypeError: node contents must be a string

Server log
[2011-01-01 14:42:40,615][crdev] DEBUG:addons.account.account:Filters: AND l.state <> 'draft' AND l.period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (1) )
[2011-01-01 14:42:40,616][crdev] DEBUG:addons.account.account:Status: SELECT
[2011-01-01 14:42:40,635][crdev] DEBUG:addons.account.account:Filters: AND l.state <> 'draft' AND l.period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (1) )
[2011-01-01 14:42:40,636][crdev] DEBUG:addons.account.account:Status: SELECT
[2011-01-01 14:42:40,669][crdev] DEBUG:addons.account.account:Filters: AND l.state <> 'draft' AND l.period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (1) )
[2011-01-01 14:42:40,670][crdev] DEBUG:addons.account.account:Status: SELECT
[2011-01-01 14:42:53,601][crdev] ERROR:web-services:[01]: Exception in call: Traceback (most recent call last):
[2011-01-01 14:42:53,601][crdev] ERROR:web-services:[02]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 72, in execute_cr
[2011-01-01 14:42:53,601][crdev] ERROR:web-services:[03]: action_res = action(self, cr, uid, data, context)
[2011-01-01 14:42:53,601][crdev] ERROR:web-services:[04]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/wizard/base_module_record_data.py", line 119, in _create_xml
[2011-01-01 14:42:53,601][crdev] ERROR:web-services:[05]: res_xml = mod.generate_xml(cr, uid)
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[06]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 472, in generate_xml
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[07]: res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[08]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 388, in _generate_object_xml
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[09]: record,noupdate = self._create_record(cr, uid, doc, rec[2], rec[5], id)
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[10]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 215, in _create_record
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[11]: field.appendChild(doc.createTextNode(val))
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[12]: File "/usr/lib/python2.6/xml/dom/minidom.py", line 1611, in createTextNode
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[13]: raise TypeError, "node contents must be a string"
[2011-01-01 14:42:53,602][crdev] ERROR:web-services:[14]: TypeError: node contents must be a string
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[01]: Exception in call: Traceback (most recent call last):
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[02]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 153, in execute_cr
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[03]: return self.execute_cr(cr, uid, data, next_state, context)
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[04]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/wizard/__init__.py", line 72, in execute_cr
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[05]: action_res = action(self, cr, uid, data, context)
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[06]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/wizard/base_module_record_data.py", line 119, in _create_xml
[2011-01-01 14:42:53,603][crdev] ERROR:web-services:[07]: res_xml = mod.generate_xml(cr, uid)
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[08]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 472, in generate_xml
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[09]: res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[10]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 388, in _generate_object_xml
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[11]: record,noupdate = self._create_record(cr, uid, doc, rec[2], rec[5], id)
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[12]: File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/addons/base_module_record/base_module_record.py", line 215, in _create_record
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[13]: field.appendChild(doc.createTextNode(val))
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[14]: File "/usr/lib/python2.6/xml/dom/minidom.py", line 1611, in createTextNode
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[15]: raise TypeError, "node contents must be a string"
[2011-01-01 14:42:53,604][crdev] ERROR:web-services:[16]: TypeError: node contents must be a string
[2011-01-01 14:42:53,605][crdev] DEBUG:web-services:netrpc: rpc-dispatching exception
Traceback (most recent call last):
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/service/netrpc_server.py", line 70, in run
    result = self.dispatch(msg[0], msg[1], msg[2:])
  File "/home/phongnt/Documents/Projects/openerp-trunk/server/bin/netsvc.py", line 499, in dispatch
    raise OpenERPDispatcherException(e, tb_s)
OpenERPDispatcherException

Version info
addons/ : <email address hidden> 4161
addons-community/ : fran@fran-pc-20101213182241-2fogs8yh5u4ma31q 292
addons-extra/ : <email address hidden> 5139
client/ : <email address hidden> 1749
server/ : launchpad_translations_on_behalf_of_openerp-20101231052227-rbby2m5910zai1xz 3199
web/ : <email address hidden> 4228

Related branches

Revision history for this message
Jamin Shah(OpenERP) (jamin-openerp) wrote :

Hello Phong,

I have checked your issue, Everything is working fine at my end.
Would you provide proper steps.

Thanks.

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
OpenBMS JSC (openbmsjsc) wrote :

When choosing the records to be exported, I choose account*

Revision history for this message
OpenBMS JSC (openbmsjsc) wrote :

When choosing the records to be exported, I choose account* ==> meaning: put account into the search box, press "Add" and select all the class highlighted. Some of these classes are ticked with "in memory" (???), then it generated error.

Revision history for this message
Jamin Shah(OpenERP) (jamin-openerp) wrote :

Hello Phong,

I have checked your scenario with latest code.But, It's working fine at my end.
Would you please check it with 6.0 RC2 version.

Thanks.

Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

Phong,

It seems like a problem due to xml.dom.
We have removed the usage of xml.dom in almost all the modules.

Removing it same over here, would solve the problem here as well.
Thanks for reporting.

Revision history for this message
DBR (OpenERP) (dbr-openerp) wrote :

Note : We did not get the error,but xml.dom looks like a culprit.

Changed in openobject-addons:
status: Incomplete → Confirmed
importance: Undecided → Low
assignee: nobody → OpenERP R&D Addons Team 2 (openerp-dev-addons2)
importance: Low → Wishlist
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi,

I just ran into this error. The error is triggered when you export a resource of type "account.account.type". The culprit is the field "sign" which is defined as follows:

    'sign': fields.selection([(-1, 'Negative'), (1, 'Positive')], ...)

Seems that the module recorder always assumes that a fields.selection is of type string. Does removing xml.dom as suggested above solve the problem in that case?

Cheers,
Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

To answer my own question:

by borrowing the logic applied in orm.py it is possible to fix the module recorder at this point.

See the attached patch.

Revision history for this message
OpenBMS JSC (openbmsjsc) wrote :
Download full text (3.2 KiB)

It happened again today when I tried to export data from product.*. The traceback is following.
I'll test the patch from Stefan.

Environment Information :
System : Linux-2.6.32-30-generic-x86_64-with-Ubuntu-10.04-lucid
OS Name : posix
Distributor ID: Ubuntu
Description: Ubuntu 10.04.2 LTS
Release: 10.04
Codename: lucid
Operating System Release : 2.6.32-30-generic
Operating System Version : #59-Ubuntu SMP Tue Mar 1 21:30:46 UTC 2011
Operating System Architecture : 64bit
Operating System Locale : en_US.UTF8
Python Version : 2.6.5
OpenERP-Client Version : 6.0.2
Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call last):
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/netsvc.py", line 489, in dispatch
    result = ExportService.getService(service_name).dispatch(method, auth, params)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/service/web_services.py", line 636, in dispatch
    res = fn(db, uid, *params)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/service/web_services.py", line 663, in exp_execute
    return self._execute(db, uid, wiz_id, datas, action, context)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/service/web_services.py", line 645, in _execute
    return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/wizard/__init__.py", line 177, in execute
    res = self.execute_cr(cr, uid, data, state, context)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/wizard/__init__.py", line 153, in execute_cr
    return self.execute_cr(cr, uid, data, next_state, context)
  File "/home/dell/Documents/Projects/openerp-server-6.0.2/bin/wizard/__init__.py", line 72, in execute_cr
    action_res = action(self, cr, uid, data, context)
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/wizard/base_module_record_data.py", line 121, in _create_xml
    res_xml = mod.generate_xml(cr, uid)
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/base_module_record.py", line 472, in generate_xml
    res_list,noupdate = self._generate_object_xml(cr, uid, rec[1], rec[2], doc, rec[3])
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/base_module_record.py", line 388, in _generate_object_xml
    record,noupdate = self._create_record(cr, uid, doc, rec[2], rec[5], id)
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/base_module_record.py", line 194, in _create_record
    childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid)
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/base_module_record.py", line 194, in _create_record
    childrecord, update = self._create_record(cr, uid, doc, fields[key]['relation'],valitem[2], newid)
  File "/home/dell/Documents/Projects/openerp-server-6.0.x/bin/addons/base_module_record/base_module_record.py", line 215, in _create_record
    field.appendChild(doc.createTextNode(val))
  File "/usr/lib/python2.6/xml/dom/minidom.py", line...

Read more...

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi,

encountered it myself today again. I have put a more elegant version of my patch in the merge proposal.

Regards,
Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Phong,

can you please confirm whether my branch fixes the problem for you? Maybe we can get the solution merged then.

Cheers,
Stefan.

Revision history for this message
OpenBMS JSC (openbmsjsc) wrote :

Hi Stefan,

Your attached patch works. Thank you. However I think there are differences between your merge proposal and your attached patch.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Phong,

thanks for testing. The branch is an improvement on the patch, removing some superfluous checks, but if the patch works for you then the branch will too.

I have created a new branch for trunk, hoping to see this fixed in 6.1.

Cheers,
Stefan.

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

This was not actually a Wishlist, thanks to Stefan and OpenBMS JSC for tracking down the issue and fixing it!

Stefan's fix has just been merged:
 - 6.0: rev 4909 rev-id: <email address hidden>
 - 6.1/trunk: rev 5514 rev-id: <email address hidden>

Changed in openobject-addons:
importance: Wishlist → Low
milestone: none → 6.0.4
status: Confirmed → Fix Released
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.