Error while connecting to Quickbooks

Hi,
I am new to ERPNext. I have successfully installed and configured the latest version. However, I am stuck at connecting to Quickbooks using erpnext_quickbooks . Since there is no activity in that repository for last few months, I am looking for a hand here. I am receiving the following error while trying to connect to Quickbooks-

Traceback (most recent call last): File "/Users/stone/frappe-bench/apps/frappe/frappe/app.py", line 55, in application response = frappe.handler.handle() File "/Users/stone/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle execute_cmd(cmd) File "/Users/stone/frappe-bench/apps/frappe/frappe/handler.py", line 40, in execute_cmd ret = frappe.call(method, **frappe.form_dict) File "/Users/stone/frappe-bench/apps/frappe/frappe/__init__.py", line 896, in call return fn(*args, **newargs) File "/Users/stone/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/erpnext_quickbooks/doctype/quickbooks_settings/quickbooks_settings.py", line 73, in quickbooks_authentication_popup quickbooks_settings.authorize_url = quickbooks.get_authorize_url() File "/Users/stone/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/pyqb/quickbooks/client.py", line 124, in get_authorize_url params={'oauth_callback': self.callback_url}) File "/Users/stone/frappe-bench/env/lib/python2.7/site-packages/rauth/service.py", line 215, in get_raw_request_token **kwargs) File "/Users/stone/frappe-bench/env/lib/python2.7/site-packages/rauth/session.py", line 181, in request req_kwargs) File "/Users/stone/frappe-bench/env/lib/python2.7/site-packages/rauth/oauth.py", line 144, in sign key = self._escape(consumer_secret) + b'&' File "/Users/stone/frappe-bench/env/lib/python2.7/site-packages/rauth/oauth.py", line 35, in _escape return quote(self._ensure_unicode(s), safe='~').encode('utf-8') File "/Users/stone/frappe-bench/env/lib/python2.7/site-packages/rauth/oauth.py", line 25, in _ensure_unicode return s.encode('utf-8') AttributeError: 'NoneType' object has no attribute 'encode'

Any idea on how to solve this issue? I appreciate your help. :slight_smile:

Can you please report this issue on github as well.

Hi @morison20,

Which branch you are using for erpnext_quickbooks connector , because update code is on develop branch .

@arpitjain06 Thanks for your reply! I used master branch. I have also tried your original code base, this morning. It doesn’t show this python error. However, after successful “Authorize”, next page has only {} as output, nothing else.

Do I need to setup something in Intuit App? What might I be doing wrong?

I will try the develop branch of this code soon and will keep you posted.

@KanchanChauhan, I will report this issue asap, thanks. :slight_smile:

UPDATE: This issue is reported here

@morison20, thanks for start testing this Connector , but My original code base is this , not that you have mentioned and please use develop branch .

  1. You do not need to setup anything in intuit app .

  2. After installing Erpnext_connector from Develop Branch,

  3. Specify certain mandatory details in Quickbooks settings page as shown in the image .

  4. Please do not check ERPNext to Quickbooks Checkbox, because syncing of data from ERPNext to QuickBooks is still in development phase.

  5. Than save the page , than click to Connect to Quickbooks Button it will connect ERPNext to QuickBooks, than select QuickBooks company.

  6. If you want to Sync data from Quickbooks to ERPNext manually, Than Click Sync Data Button, if not than the Scheduler runs every hour

Thanks & Regards
Arpit Jain

4 Likes

@arpitjain06 , Thank you very much for your detail response. I have finally managed to connect to intuit app successfully following your instruction. The Consumer Key and Consumer Secret were hardcoded in the develop version, so I had to modify a little.

I very much appreciate your assistance. :slight_smile:

@morison20,

Yes, Consumer Key and Consumer Secret keys are hardcoded because these are Production Keys of ERPNext Quickbooks App , which is going to be listed on the QuickBoooks App store.
It is not at all necessary to change these keys. That’s why it is hardcoded. By using these keys you can connect ERPNext to any QuickBooks Online account.

Thanks.
Arpit Jain

Hello @arpitjain06, I am trying to set up your application in an erpnext environment but whe nI click the connect button all I get for companies are the sandbox companies. Is there a step I happen to be missing? Or should I try to import my production company into one of the sandbox, or maybe it has to wait for Intuit to approve it and add it to the store.

Any help would be appreciated.

I am using:
erpnext 7.2.3
frappe 7.2.4

And I have switched erpnext_quickbooks to the develop branch.

@arpitjain06 @morison20 I am only have sandbox companies showing up.

I also get this error while installing the connector:
@arpitjain06 @rmehta

[frappe@erpnext frappe-bench]$ bench install-app erpnext_quickbooks Installing erpnext_quickbooks... Updating erpnext_quickbooks : [========================================] Traceback (most recent call last): File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module> main() File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main click.Group(commands=commands)(prog_name='bench') File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 716, in __call__ return self.main(*args, **kwargs) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 696, in main rv = self.invoke(ctx) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1060, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1060, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 889, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 534, in invoke return callback(*args, **kwargs) File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func ret = f(frappe._dict(ctx.obj), *args, **kwargs) File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 152, in install_app _install_app(app, verbose=context.verbose) File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 136, in install_app add_to_installed_apps(name) File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 157, in add_to_installed_apps post_install(rebuild_website) File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 221, in post_install init_singles() File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 239, in init_singles doc = frappe.new_doc(single) File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 572, in new_doc return get_new_doc(doctype, parent_doc, parentfield, as_dict=as_dict) File "/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py", line 19, in get_new_doc frappe.local.new_doc_templates[doctype] = make_new_doc(doctype) File "/home/frappe/frappe-bench/apps/frappe/frappe/model/create_new.py", line 37, in make_new_doc "docstatus": 0 File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 596, in get_doc return frappe.model.document.get_doc(arg1, arg2) File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 48, in get_doc controller = get_controller(doctype) File "/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py", line 34, in get_controller module = load_doctype_module(doctype, module_name) File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/utils.py", line 173, in load_doctype_module raise ImportError, 'Module import failed for {0} ({1})'.format(doctype, module_name) ImportError: Module import failed for Student Batch Attendance Tool (erpnext.schools.doctype.student_batch_attendance_tool.student_batch_attendance_tool)

Any help would be appreciated. :slight_smile:

I’ve managed to get a bit further by replacing the consumer secret and the consumer key with some production keys as a way to get us jump started but we keep running into these error now:

  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/api.py", line 51, in sync_quickbooks_resources
    sync_from_quickbooks_to_erp(quickbooks_settings)
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/api.py", line 110, in sync_from_quickbooks_to_erp
    sync_si_orders(quickbooks_obj)
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/sync_orders.py", line 17, in sync_si_orders
    get_qb_invoice =  qb_invoice['QueryResponse']
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/sync_orders.py", line 21, in sync_qb_si_orders
    for qb_orders in get_qb_invoice['Invoice']:
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/sync_orders.py", line 36, in valid_customer_and_product
    if not frappe.db.get_value("Customer", {"quickbooks_cust_id": customer_id}, "name"):
NameError: global name 'json' is not defined
                                         | NULL       | sync_quickbooks_resources                        |
+------------+----------------------------+----------------------------+---------------+---------------+-----------+--------+-------------+------------+-----+--------+--------------+-----------+---------------------+-----------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------+--------------------------------------------------+ ````

and also this:

```` | a17ddc7267 | 2017-01-03 16:47:33.210199 | 2017-01-03 16:47:33.213156 | Administrator | Administrator |         0 | NULL   | NULL        | NULL       |   0 | Error  | {}           | NULL      | sync has terminated | NULL      | NULL    | Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/api.py", line 50, in sync_quickbooks_resources
    validate_quickbooks_settings(quickbooks_settings)
  File "/home/frappe/frappe-bench/apps/erpnext_quickbooks/erpnext_quickbooks/api.py", line 123, in validate_quickbooks_settings
    quickbooks_settings.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 223, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 249, in _save
    self.check_if_latest()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 502, in check_if_latest
    where doctype=%s and field='modified' for update''', self.doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database.py", line 137, in sql
    self._cursor.execute(query, values)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/home/frappe/frappe-bench/env/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1213, 'Deadlock found when trying to get lock; try restarting transaction')
 | NULL       | sync_quickbooks_resources ````

inside the `tabQuickbooks Log` table.

Any help would be appreciated.

P.S. Should I be posting these on github as well? or instead of?

@samjaninf @woakes070048 , I will look into this

@arpitjain06 thanks. How to test it more soon

@arpitjain06 is there any update on this?

@arpitjain06 I have not been able to get a complete sync is there anything that you can recommend?