Incoming Mail with attachment error

Bug #1031694 reported by inglorious
34
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Confirmed
Medium
OpenERP Publisher's Warranty Team

Bug Description

Hi,

I have installed the stable server build openerp-6.1-20120726-233351 on ubuntu 10.04 LTS and ubuntu 12.04 LTS. If I setup an incoming googlemail server, it works, and the mails are fetched correctly. But if an E-Mail has an attachment, I got the following error:

================================= Begin Code: ==================================

2012-08-01 09:50:27,015 7409 ERROR ? fetchmail: Failed to fetch mail from pop server XEO Order Test
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/fetchmail/fetchmail.py", line 220, in fetch_mail
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/mail/mail_thread.py", line 426, in message_process
    res_id = create_record(msg)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/mail/mail_thread.py", line 400, in create_record
    context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/mail/mail_thread.py", line 173, in message_new
    self.message_append_dict(cr, uid, [res_id], msg_dict, context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/mail/mail_thread.py", line 344, in message_append_dict
    context = context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/mail/mail_thread.py", line 263, in message_append
    to_attach.append(ir_attachment.create(cr, uid, data_attach, context=context))
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/base_calendar/base_calendar.py", line 1633, in create
    return super(ir_attachment, self).create(cr, uid, vals, context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/base/ir/ir_attachment.py", line 117, in create
    return super(ir_attachment, self).create(cr, uid, values, context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/osv/orm.py", line 4239, in create
    self.pool.get(object)._store_set_values(cr, user, ids, fields2, context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/osv/orm.py", line 4388, in _store_set_values
    result = self._columns[f].get(cr, self, ids, f, SUPERUSER_ID, context=context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/osv/fields.py", line 1129, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/addons/base/ir/ir_attachment.py", line 132, in _name_get_resname
    res = model_pool.name_get(cr,uid,[res_id],context)
  File "/usr/local/lib/python2.7/dist-packages/openerp-6.1_20120726_233351-py2.7.egg/openerp/osv/orm.py", line 2262, in name_get
    [self._rec_name], context, load='_classic_write')]
KeyError: 'name'

============================ / End Code =============================

As you see, the exception is thrown at 132 int ir_attachment.py:

                 model_pool = self.pool.get(model_object)
                  res = model_pool.name_get(cr,uid,[res_id],context)
                 res_name = res and res[0][1] or False

If the exception is thrown, the test res_name wont be reached. I made a try-catch block.

129 model_pool = self.pool.get(model_object)
130 # inglorious, 1.8.12
131 try:
132 res = model_pool.name_get(cr,uid,[res_id],context)
133 except Exception, e:
134 res = False
135
136 res_name = res and res[0][1] or False

If the exception is thrown, res will be set to false. The solution works for me.

affects: openobject-server → openobject-addons
Revision history for this message
Ravish(OpenERP) (rmu-openerp) wrote :

Hello inglorious,

I have checked your issue with lot of object (created new record as field in incoming server) like crm,sale,project. But can't find this error.Would you please provide your scenario on this issue or video media of your scenario.
Usually we find this Key Error: 'name' ,when object d'nt find name field when name_get method calls then we provide it with using _recname =''

Waiting for your reply..!!

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
inglorious (kihyoun) wrote :

I forgot to mention, that I create a record "mail.thread", because I want to save the E-Mails in Inbox. I no attachment is there, it works with mail.thread record. But if there is an attachment in the E-Mail, then the error comes.

Revision history for this message
Ravish(OpenERP) (rmu-openerp) wrote :

Hello inglorious,

I have checked again with mail.thread object.But it's working fine.
All I have shown in attached video please take a look.

Thanks for post..!!!

Revision history for this message
inglorious (kihyoun) wrote :

Can you explain what exactly you mean by "providing recname"?

The table mail_thread doesn't have a name attribute, that is the reason why the name_get call throws an error. A friend of mine faced the same issue, and as a solution added the name field to the mail_thread table.

Can you explain, how you provide "_recname"? What are the steps to do? And is it right, that without providing _recname, you get the same error?

Revision history for this message
Ravish(OpenERP) (rmu-openerp) wrote :

Hello inglorious,

let me explain suppose I have an object with:

_name = 'citrus.load'
_rec_name = 'load_id'

_columns = { 'load_id: fields.integer('Load ID'),
etc...
}

When name_get method search for name as default if your object has no field name "Name" in that case you have to specify _rec_name like load_id is refer as name. Also adding name field on object it can resolved.

Thanks..!!!

Revision history for this message
Ravish(OpenERP) (rmu-openerp) wrote :

Hello ,

I have checked again find the same result and as per comment #3 and #4, I'm closing this issue.

Thanks for post and response..!!

Changed in openobject-addons:
assignee: nobody → Ravish(OpenERP) (rmu-openerp)
status: Incomplete → Invalid
Changed in openobject-addons:
assignee: Ravish(OpenERP) (rmu-openerp) → nobody
Revision history for this message
Jignesh Rathod(OpenERP) (jir-openerp) wrote :

Hello inglorious ,

I have checked this issue with trunk as well as 6.1, It's working fine with latest
trunk.It,s produceble when create mail.thread record from fetchmail with attachment
in 6.1.So I am assiging this issue to OPW team.

Thanks for reporting!

Changed in openobject-addons:
assignee: nobody → OpenERP Publisher's Warranty Team (openerp-opw)
importance: Undecided → Medium
status: Invalid → Confirmed
Revision history for this message
inglorious (kihyoun) wrote :

Hi,

thank you as well!!!
Do you think, my solution will go into trunk? In this case I would be glad to see my nickname in the source-code :)

Best,
Inglorious

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.