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’domain.com’, ‘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/background_jobs.py”, line 95, in execute_job
method(**kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 704, in pull_from_email_account
email_account.receive()
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, 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/email_account.py”, 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/email_account.py”, line 374, in insert_communication\n self.set_thread(communication, email)\n File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, 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/email_account.py”, line 498, in create_new_parent\n parent.insert(ignore_permissions=True)\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 218, in insert\n self.run_before_save_methods()\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 859, in run_before_save_methods\n self.run_method(“validate”)\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 755, in run_method\n out = Document.hook(fn)(self, *args, **kwargs)\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1024, in composer\n return composed(self, method, *args, **kwargs)\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1007, in runner\n add_to_return_value(self, fn(self, *args, **kwargs))\n File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, 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/lead.py”, line 26, in validate\n self.set_lead_name()\n File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/lead.py”, line 104, in set_lead_name\n frappe.db.set_value(“Lead”, self.name, “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/email_account.py”, line 275, in receive
communication = self.insert_communication(msg, args=args)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 374, in insert_communication
self.set_thread(communication, email)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 425, in set_thread
parent = self.create_new_parent(communication, email)
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py”, line 498, in create_new_parent
parent.insert(ignore_permissions=True)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 218, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 859, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 755, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1024, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1007, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 749, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/lead.py”, line 26, in validate
self.set_lead_name()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/crm/doctype/lead/lead.py”, line 104, in set_lead_name
frappe.db.set_value(“Lead”, self.name, “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 https://github.com/frappe/bench
76aff28…f85cbc8 master -> origin/master
Updating 76aff28…f85cbc8
error: Your local changes to the following files would be overwritten by merge:
.travis.yml
playbooks/develop/includes/setup_erpnext.yml
playbooks/develop/install.yml
playbooks/prerequisites/roles/mariadb/defaults/main.yml
playbooks/prerequisites/roles/mariadb/tasks/debian.yml
playbooks/prerequisites/roles/mariadb/tasks/ubuntu.yml
playbooks/prerequisites/roles/mariadb/templates/mariadb_centos.repo.j2
playbooks/prerequisites/roles/mariadb/templates/mariadb_ubuntu.list.j2
playbooks/prerequisites/roles/nginx/tasks/main.yml
playbooks/production/includes/setup_bench_production.yml
playbooks/production/includes/setup_inputrc.yml
Please, commit your changes or stash them before you can merge.
Aborting
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/cli.py”, line 40, in cli
bench_command()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/home/frappe/.bench/bench/commands/update.py”, line 34, in update
update_bench()
File “/home/frappe/.bench/bench/utils.py”, line 256, in update_bench
exec_cmd(“git pull”, cwd=cwd)
File “/home/frappe/.bench/bench/utils.py”, 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”, self.name, “lead_name”, self.organization_name)
AttributeError: ‘Lead’ object has no attribute ‘organization_name’

looking at the difference between opportunity.py and lead.py 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 lead.py differently when doing a pull - see below (code is from default lead.py)…

def set_lead_name(self):
	if not self.lead_name:
		frappe.db.set_value("Lead", self.name, "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.