[7.0] "TypeError: 'NoneType' object is not iterable" when creating PDF attachments

Bug #1094423 reported by David Deluria
112
This bug affects 14 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP R&D Addons Team 1

Bug Description

Using Latest build from Launchpad (debian src)

Installing the Knowledge Management System will break any attempt to email quotations/invoices to customers.

Server Traceback (most recent call last):
  File "/home/openerp/web/addons/web/session.py", line 87, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/netsvc.py", line 281, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/service/web_services.py", line 614, in dispatch
    res = fn(db, uid, *params)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/osv/osv.py", line 169, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/osv/osv.py", line 123, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/osv/osv.py", line 179, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/openerp-7.0alpha-py2.7.egg/openerp/osv/osv.py", line 166, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/openerp/addons/email_template/wizard/mail_compose_message.py", line 85, in onchange_template_id
    values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context))
  File "/home/openerp/addons/document/document.py", line 121, in create
    vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), None)
  File "/home/openerp/addons/document/document.py", line 132, in _index
    mime, icont = cntIndex.doIndex(data, datas_fname, file_type or None, None)
TypeError: 'NoneType' object is not iterable

To replicate.

Create new database using demostration data.

- Install Sales Management Module & eInvoicing and Payments

Go to Sales > quotations, select S0008 and click on Send by Email... this will WORK

- Install Knowledge Management System and attempt to send by email any existing Quotation or Invoice from demo data to get the error.

Revision history for this message
David Deluria (dave-deluria) wrote :

I have done some further tests and I can install Knowledge Management without the Document Management system and sending emails works.

It's when the Document Management System is installed that breaks sending email invoices/quotations.

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :

Hello David,

I have checked you issue with latest openerp_7.0alpha-20121206-000102-1_all.deb. But I did not face any problem.So, would you please try with latest ? And also provide us more information.

Thanks and waiting for your replay.. !!!

Revision history for this message
Twinkle Christian(OpenERP) (tch-openerp) wrote :
Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
David Deluria (dave-deluria) wrote :

Thank you for the comment.

The version I'm using is the latest build straight from launchpad (installed via bzr) and built a new database using it.

Since there no installation package that is available yet, I am now using bzr sources to test the latest builds and the error is occuring in those builds.

I can't replicate it using runbot though so it's a bit harder to find.

Revision history for this message
David Deluria (dave-deluria) wrote :

Pls close this bug.

I have just installed the latest nightly build (12/30/2012) and I cannot replicate it anymore.

Thanks.

Revision history for this message
Amit Bhavsar (Open ERP) (amb-openerp) wrote :

Hello David,

As per your comment#5, I am closing this Issue.

Thanks!

Changed in openobject-addons:
status: Incomplete → Invalid
Revision history for this message
Alan Paul Stadnik (alan-8) wrote :

Sorry I posted my comment on a duplicate of this bug. I uploaded a video to
lp: 1101621. Don't wanna "spam" it here once again ;-)

Hi,
I thing that I got the same or similar problem, but it's not fixable with installing popper-utils.
At time it's impossible to attache a file to massages or prducts etc.

I'm running a Ubuntu 12.04 system with openerp 7.0 (trunk 04.02.2013)

Revision history for this message
jehan (jens-e-hansen) wrote :

i agree with last comment.

- installed poppler-utils
- installed latest debian nightly package
- loaded demo data and document addon
- tried to attach a pdf to a task
> openerp loads for ever

in the server log i can see this message:
"POST /Copy%20text%20t%20/web/binary/upload_attachment HTTP/1.1" 404 -

Revision history for this message
Ian Beardslee (ibeardslee) wrote :

Version 7.0-20130214-002355 from the .deb
Ubuntu 12.04
PostgreSQL 9.1

WIth the default install I was able to attach a pdf. Settings >> Technical >> Low Level Objects >> Attachments.
After installing the knowledge module it failed with a

  File "/usr/lib/pymodules/python2.7/openerp/addons/document/document.py", line 121, in create
    vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), None)
  File "/usr/lib/pymodules/python2.7/openerp/addons/document/document.py", line 132, in _index
    mime, icont = cntIndex.doIndex(data, datas_fname, file_type or None, None)
TypeError: 'NoneType' object is not iterable

I installed the poppler-utils and it worked properly.

For those still with problems (and running PostgreSQL 9.1), there was some earlier documentation about ensuring that postgres was configured with "bytea_output = escape". Not sure if that is still the case, but the default in PostgreSQL 9.1 is "bytea_output = hex" This needs to be changed in "/etc/postgresql/9.1/main/postgresql.conf" and postgres restarted.

Revision history for this message
Ian Beardslee (ibeardslee) wrote :

Correct line is ...

bytea_output = 'escape'

Revision history for this message
Alan Paul Stadnik (alan-8) wrote :

HI Ian,
thx for this. I tried it just a few minutes ago. It still doesnt work...
I'm able to upload files via knowledge, but ist impossible to attach files to items like products, messages etc.

Revision history for this message
jehan (jens-e-hansen) wrote :

i can confirm that it is not possible to attach a file (not only pdf) even if "bytea_output = 'escape'" ist set and poppler-utils are installed

Revision history for this message
Landis (larnold) wrote :

I did a BZR Update last weekend (about 2-20-13).

Then installed knowledge which seems to have been a mistake.

I can send emails from Opportunities.

I can no longer send emails via Quotations/Sales Orders or RFQ's.

I will try a new BZR but expect this will not work.

Searching on the following returns many instances of the basic problem (called in the middle of the Server Error)

TypeError: 'NoneType' object is not iterable
ERROR openerp.netsvc: 'NoneType' object is
not iterable

Revision history for this message
Andreas Brueckl (andreas-brueckl) wrote :

After installing "popper-utils" (Linux) or "XPDF3" (Windows) you have to restart the server.
This is required because otherwise the program "pdf2text" is not found by OpenERP. The restart reloads the environment PATH and the path of "pdf2text" will be added.

I was able to resolve this problem under Windows 2008 Server by installing "XPDF3" and restarting OpenERP Server.

Revision history for this message
Alan Paul Stadnik (alan-8) wrote :

Hi Folks,
I found something interessting for unable to "attache file".
please take a look at this.

https://bugs.launchpad.net/openobject-addons/+bug/1096487

I changed my openerp language to english and everthing works fine.
I copied the files like described, but i'm not sure if i'm done it right. perhaps some can help how to fix it like explained in 1096487

thx and bye

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

Re-opening, as the bug can still be reproduced with the latest 7.0 when no version of `pdftotext` is available. One of the ways to have it available is to install the 'poppler-utils' package on Linux.

Changed in openobject-addons:
importance: Undecided → Medium
milestone: none → 7.0
status: Invalid → Confirmed
summary: - [7.0] Knowledge Management System breaks Sending Email
+ [7.0] "TypeError: 'NoneType' object is not iterable" when creating PDF
+ attachments
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

This patch should solve the issue - it's being tested by our OpenERP Enterprise team before applying it.

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
jehan (jens-e-hansen) wrote :

i can confirm that attachments work if you use english language as described in post #15.
attachments do not work if you use german language.

@alan-8: where can in find the description you mentioned?

the bug #1096487 is marked as "fix released" but i'm not able to attach a png file with debian nightly build 7.0-20130306-002055-1.

Revision history for this message
Alan Paul Stadnik (alan-8) wrote :

hi jehan,
its hidden in the text *g*

--> "Copy text \t\n" in de.po

You have to edit the file, remove "Copy text \t\n"
http://bazaar.launchpad.net/~openerp/openobject-server/7.0/view/head:/openerp/addons//mail/i18n/de.po#L667.

This fixes the problem with attaching files to a message, but not by attaching to a item like product etc.

I installed a new openerp database choosing language english. loaded german as language via settings.
After this I changed the user language back to german, so on, now it works.

Revision history for this message
jehan (jens-e-hansen) wrote :

ok thx for this valuable hint.

i also was able to resolve this issue by
- login as admin
- go to setting > translations > load a translation
- select language (e.g. german/deutsch)
- tick overwrite existing terms
- logout and login as user

Amit Parik (amit-parik)
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

This issue has been fixed in addons 7.0 as of revision 8818 rev-id: <email address hidden>.
Please note that this fix will simply suppress the errors in case a PDF file cannot be indexed. It is still necessary to install a version of "pdftotext" on the system if you want to actually index the contents of PDF attachments (to make full-text search possible in the Documents list of the Knowledge menu)

Thanks for reporting and thanks for your patience!

Changed in openobject-addons:
status: In Progress → Fix Released
Revision history for this message
nhat_duy_to (duynhat) wrote :

=== modified file 'openerp/openerp/addons/document/document.py

Edit 2 method ( create, _index )

def create(self, cr, uid, vals, context=None):
        if context is None:
            context = {}
        vals['parent_id'] = context.get('parent_id', False) or vals.get('parent_id', False)
        # take partner from uid
        if vals.get('res_id', False) and vals.get('res_model', False) and not vals.get('partner_id', False):
            vals['partner_id'] = self.__get_partner_id(cr, uid, vals['res_model'], vals['res_id'], context)
# if vals.get('datas', False):
# vals['file_type'], vals['index_content'] = self._index(cr, uid, vals['datas'].decode('base64'), vals.get('datas_fname', False), None)
        return super(document_file, self).create(cr, uid, vals, context)

def _index(self, cr, uid, data, datas_fname, file_type):
# mime, icont = cntIndex.doIndex(data, datas_fname, file_type or None , None)
# icont_u = ustr(icont)
# return mime, icont_u
        return False

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.