Error: pull_from_email_account and email_account.receive

Hi all, I keep getting these error messages in my log…

Error 1: pull_from_email_account

{‘retry’: 0, ‘log’: <function log at 0x7f4c4e53c320>, ‘site’: u’’, ‘event’: u’all’, ‘method_name’: u’pull_from_email_account’, ‘method’: <function pull_from_email_account at 0x7f4c4da5aed8>, ‘user’: u’Administrator’, ‘kwargs’: {‘email_account’: u’Obinna’}, ‘async’: True, ‘job_name’: u’pull_from_email_account|Obinna’}
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/utils/”, line 95, in execute_job
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 704, in pull_from_email_account
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 298, in receive
raise Exception(frappe.as_json(exceptions))
Exception: [
“Traceback (most recent call last):\n File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/", line 275, in receive\n communication = self.insert_communication(msg, args=args)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/", line 374, in insert_communication\n self.set_thread(communication, email)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/", line 425, in set_thread\n parent = self.create_new_parent(communication, email)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/", line 498, in create_new_parent\n parent.insert(ignore_permissions=True)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 218, in insert\n self.run_before_save_methods()\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 859, in run_before_save_methods\n self.run_method("validate")\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 755, in run_method\n out = Document.hook(fn)(self, *args, **kwargs)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1024, in composer\n return composed(self, method, *args, **kwargs)\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 1007, in runner\n add_to_return_value(self, fn(self, *args, **kwargs))\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/", line 749, in \n fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)\n File "/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/", line 26, in validate\n self.set_lead_name()\n File "/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/", line 104, in set_lead_name\n frappe.db.set_value("Lead",, "lead_name", self.organization_name)\nAttributeError: ‘Lead’ object has no attribute ‘organization_name’\n”

Error 2: email_account.receive

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 275, in receive
communication = self.insert_communication(msg, args=args)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 374, in insert_communication
self.set_thread(communication, email)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 425, in set_thread
parent = self.create_new_parent(communication, email)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/”, line 498, in create_new_parent
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 218, in insert
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 859, in run_before_save_methods
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 755, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 1024, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 1007, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 749, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/”, line 26, in validate
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/”, line 104, in set_lead_name
frappe.db.set_value(“Lead”,, “lead_name”, self.organization_name)
AttributeError: ‘Lead’ object has no attribute ‘organization_name’

Lead Doctype, don’t have field organization_name. Did you customized it in lead doctype. please update your bench this may solve your problem

I can see “Organisational Name” in the DocType and I don’t remember customising the LEAD DocType.

On Bench Update, I get this

frappe@muna:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
remote: Counting objects: 107, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 107 (delta 73), reused 92 (delta 58), pack-reused 0
Receiving objects: 100% (107/107), 21.40 KiB | 0 bytes/s, done.
Resolving deltas: 100% (73/73), completed with 27 local objects.
From GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps
76aff28…f85cbc8 master → origin/master
Updating 76aff28…f85cbc8
error: Your local changes to the following files would be overwritten by merge:
Please, commit your changes or stash them before you can merge.
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/frappe/.bench/bench/”, line 40, in cli
File “/usr/local/lib/python2.7/dist-packages/click/”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/”, line 34, in update
File “/home/frappe/.bench/bench/”, line 256, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/”, line 140, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: git pull

Thanks for your timely response.

Seems like there are lot of changes you made. You’ll have to do git stash to save this changes for a time being and then run bench update. After that you can easily get back the changes you made by git stash apply.

I have the same issue when setting incoming email as leads instead of opportunities…

frappe.db.set_value(“Lead”,, “lead_name”, self.organization_name)
AttributeError: ‘Lead’ object has no attribute ‘organization_name’

looking at the difference between and the difference is Opportunity sets the Company Name Id to self.company_name which exists and Lead tries to set Company Name to self.organization_name which doesn’t exist by default in lead DocType.

Is there a reason for this - I’m assuming it is just left over code from making the change from company_name to organization_name at some point in time.

You would only see this issue if you are using the incoming email and change the default from Opportunity to Lead since it calls on the differently when doing a pull - see below (code is from default…

def set_lead_name(self):
	if not self.lead_name:
		frappe.db.set_value("Lead",, "lead_name", self.organization_name) <---- isn't defined in DocType

def _make_customer(source_name, target_doc=None, ignore_permissions=False):
def set_missing_values(source, target):
if source.company_name:
target.customer_type = “Company”
target.customer_name = source.company_name <----- uses company_name when user is manually filling out form

Just thinking out loud here…

By default when the Default Inbox email account is set to Enable Incoming the setting is append to Opportunity.

So when someone emails the account they are created as an opportunity based on a auto-generated lead

Is the goal then to automatically make someone an opportunity from a lead since they are contacting/replying to you and it isn’t just a cold email/call (may be considered a warm lead in essence)

Cool, I didn’t know anyone else had same issues. I’ll try setting it to opportunity.