commit
d02c8ad898
@ -7,7 +7,9 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from requests_oauthlib import OAuth2Session
|
from requests_oauthlib import OAuth2Session
|
||||||
import json, requests
|
import json
|
||||||
|
import requests
|
||||||
|
import traceback
|
||||||
from erpnext import encode_company_abbr
|
from erpnext import encode_company_abbr
|
||||||
|
|
||||||
# QuickBooks requires a redirect URL, User will be redirect to this URL
|
# QuickBooks requires a redirect URL, User will be redirect to this URL
|
||||||
@ -32,7 +34,6 @@ def callback(*args, **kwargs):
|
|||||||
class QuickBooksMigrator(Document):
|
class QuickBooksMigrator(Document):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(QuickBooksMigrator, self).__init__(*args, **kwargs)
|
super(QuickBooksMigrator, self).__init__(*args, **kwargs)
|
||||||
from pprint import pprint
|
|
||||||
self.oauth = OAuth2Session(
|
self.oauth = OAuth2Session(
|
||||||
client_id=self.client_id,
|
client_id=self.client_id,
|
||||||
redirect_uri=self.redirect_url,
|
redirect_uri=self.redirect_url,
|
||||||
@ -46,7 +47,9 @@ class QuickBooksMigrator(Document):
|
|||||||
if self.company:
|
if self.company:
|
||||||
# We need a Cost Center corresponding to the selected erpnext Company
|
# We need a Cost Center corresponding to the selected erpnext Company
|
||||||
self.default_cost_center = frappe.db.get_value('Company', self.company, 'cost_center')
|
self.default_cost_center = frappe.db.get_value('Company', self.company, 'cost_center')
|
||||||
self.default_warehouse = frappe.get_all('Warehouse', filters={"company": self.company, "is_group": 0})[0]["name"]
|
company_warehouses = frappe.get_all('Warehouse', filters={"company": self.company, "is_group": 0})
|
||||||
|
if company_warehouses:
|
||||||
|
self.default_warehouse = company_warehouses[0].name
|
||||||
if self.authorization_endpoint:
|
if self.authorization_endpoint:
|
||||||
self.authorization_url = self.oauth.authorization_url(self.authorization_endpoint)[0]
|
self.authorization_url = self.oauth.authorization_url(self.authorization_endpoint)[0]
|
||||||
|
|
||||||
@ -493,7 +496,7 @@ class QuickBooksMigrator(Document):
|
|||||||
"account_currency": customer["CurrencyRef"]["value"],
|
"account_currency": customer["CurrencyRef"]["value"],
|
||||||
"company": self.company,
|
"company": self.company,
|
||||||
})[0]["name"]
|
})[0]["name"]
|
||||||
except Exception as e:
|
except Exception:
|
||||||
receivable_account = None
|
receivable_account = None
|
||||||
erpcustomer = frappe.get_doc({
|
erpcustomer = frappe.get_doc({
|
||||||
"doctype": "Customer",
|
"doctype": "Customer",
|
||||||
@ -1252,8 +1255,6 @@ class QuickBooksMigrator(Document):
|
|||||||
|
|
||||||
|
|
||||||
def _log_error(self, execption, data=""):
|
def _log_error(self, execption, data=""):
|
||||||
import json, traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
frappe.log_error(title="QuickBooks Migration Error",
|
frappe.log_error(title="QuickBooks Migration Error",
|
||||||
message="\n".join([
|
message="\n".join([
|
||||||
"Data",
|
"Data",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user