Merge branch 'develop' of https://github.com/frappe/erpnext into develop
This commit is contained in:
commit
7f2623da09
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"add_total_row": 0,
|
"add_total_row": 0,
|
||||||
"creation": "2019-09-23 16:35:02.836134",
|
"creation": "2019-09-23 16:35:02.836134",
|
||||||
"disable_prepared_report": 0,
|
"disable_prepared_report": 1,
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Report",
|
"doctype": "Report",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": "Yes",
|
"is_standard": "Yes",
|
||||||
"modified": "2019-09-23 16:35:02.836134",
|
"modified": "2019-10-22 13:00:31.539726",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Fixed Asset Register",
|
"name": "Fixed Asset Register",
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from frappe.utils import cstr
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
filters = frappe._dict(filters or {})
|
filters = frappe._dict(filters or {})
|
||||||
@ -149,12 +150,12 @@ def get_finance_book_value_map(finance_book=''):
|
|||||||
FROM `tabAsset Finance Book`
|
FROM `tabAsset Finance Book`
|
||||||
WHERE
|
WHERE
|
||||||
parentfield='finance_books'
|
parentfield='finance_books'
|
||||||
AND finance_book=%s''', (finance_book)))
|
AND ifnull(finance_book, '')=%s''', cstr(finance_book)))
|
||||||
|
|
||||||
def get_purchase_receipt_supplier_map():
|
def get_purchase_receipt_supplier_map():
|
||||||
return frappe._dict(frappe.db.sql(''' Select
|
return frappe._dict(frappe.db.sql(''' Select
|
||||||
pr.name, pr.supplier
|
pr.name, pr.supplier
|
||||||
FROM `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
|
FROM `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pri
|
||||||
WHERE
|
WHERE
|
||||||
pri.parent = pr.name
|
pri.parent = pr.name
|
||||||
AND pri.is_fixed_asset=1
|
AND pri.is_fixed_asset=1
|
||||||
@ -164,7 +165,7 @@ def get_purchase_receipt_supplier_map():
|
|||||||
def get_purchase_invoice_supplier_map():
|
def get_purchase_invoice_supplier_map():
|
||||||
return frappe._dict(frappe.db.sql(''' Select
|
return frappe._dict(frappe.db.sql(''' Select
|
||||||
pi.name, pi.supplier
|
pi.name, pi.supplier
|
||||||
FROM `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii
|
FROM `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii
|
||||||
WHERE
|
WHERE
|
||||||
pii.parent = pi.name
|
pii.parent = pi.name
|
||||||
AND pii.is_fixed_asset=1
|
AND pii.is_fixed_asset=1
|
||||||
|
@ -29,7 +29,8 @@ def sync_sales_order(order, request_id=None):
|
|||||||
validate_item(order, shopify_settings)
|
validate_item(order, shopify_settings)
|
||||||
create_order(order, shopify_settings)
|
create_order(order, shopify_settings)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
make_shopify_log(status="Error", message=e.message, exception=False)
|
make_shopify_log(status="Error", exception=e)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
make_shopify_log(status="Success")
|
make_shopify_log(status="Success")
|
||||||
|
|
||||||
@ -42,9 +43,9 @@ def prepare_sales_invoice(order, request_id=None):
|
|||||||
sales_order = get_sales_order(cstr(order['id']))
|
sales_order = get_sales_order(cstr(order['id']))
|
||||||
if sales_order:
|
if sales_order:
|
||||||
create_sales_invoice(order, shopify_settings, sales_order)
|
create_sales_invoice(order, shopify_settings, sales_order)
|
||||||
make_shopify_log(status="Success")
|
make_shopify_log(status="Success")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
make_shopify_log(status="Error", exception=True)
|
make_shopify_log(status="Error", exception=e, rollback=True)
|
||||||
|
|
||||||
def prepare_delivery_note(order, request_id=None):
|
def prepare_delivery_note(order, request_id=None):
|
||||||
frappe.set_user('Administrator')
|
frappe.set_user('Administrator')
|
||||||
@ -56,8 +57,8 @@ def prepare_delivery_note(order, request_id=None):
|
|||||||
if sales_order:
|
if sales_order:
|
||||||
create_delivery_note(order, shopify_settings, sales_order)
|
create_delivery_note(order, shopify_settings, sales_order)
|
||||||
make_shopify_log(status="Success")
|
make_shopify_log(status="Success")
|
||||||
except Exception:
|
except Exception as e:
|
||||||
make_shopify_log(status="Error", exception=True)
|
make_shopify_log(status="Error", exception=e, rollback=True)
|
||||||
|
|
||||||
def get_sales_order(shopify_order_id):
|
def get_sales_order(shopify_order_id):
|
||||||
sales_order = frappe.db.get_value("Sales Order", filters={"shopify_order_id": shopify_order_id})
|
sales_order = frappe.db.get_value("Sales Order", filters={"shopify_order_id": shopify_order_id})
|
||||||
@ -97,7 +98,7 @@ def create_sales_order(shopify_order, shopify_settings, company=None):
|
|||||||
message = 'Following items are exists in order but relevant record not found in Product master'
|
message = 'Following items are exists in order but relevant record not found in Product master'
|
||||||
message += "\n" + ", ".join(product_not_exists)
|
message += "\n" + ", ".join(product_not_exists)
|
||||||
|
|
||||||
make_shopify_log(status="Error", message=message, exception=True)
|
make_shopify_log(status="Error", exception=e, rollback=True)
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@ -12,23 +12,38 @@ class ShopifyLog(Document):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def make_shopify_log(status="Queued", message=None, exception=False):
|
def make_shopify_log(status="Queued", exception=None, rollback=False):
|
||||||
# if name not provided by log calling method then fetch existing queued state log
|
# if name not provided by log calling method then fetch existing queued state log
|
||||||
|
make_new = False
|
||||||
|
|
||||||
if not frappe.flags.request_id:
|
if not frappe.flags.request_id:
|
||||||
return
|
make_new = True
|
||||||
|
|
||||||
log = frappe.get_doc("Shopify Log", frappe.flags.request_id)
|
if rollback:
|
||||||
|
|
||||||
if exception:
|
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
log = frappe.get_doc({"doctype":"Shopify Log"}).insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
log.message = message if message else ''
|
if make_new:
|
||||||
|
log = frappe.get_doc({"doctype":"Shopify Log"}).insert(ignore_permissions=True)
|
||||||
|
else:
|
||||||
|
log = log = frappe.get_doc("Shopify Log", frappe.flags.request_id)
|
||||||
|
|
||||||
|
log.message = get_message(exception)
|
||||||
log.traceback = frappe.get_traceback()
|
log.traceback = frappe.get_traceback()
|
||||||
log.status = status
|
log.status = status
|
||||||
log.save(ignore_permissions=True)
|
log.save(ignore_permissions=True)
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
|
|
||||||
|
def get_message(exception):
|
||||||
|
message = None
|
||||||
|
|
||||||
|
if hasattr(exception, 'message'):
|
||||||
|
message = exception.message
|
||||||
|
elif hasattr(exception, '__str__'):
|
||||||
|
message = e.__str__()
|
||||||
|
else:
|
||||||
|
message = "Something went wrong while syncing"
|
||||||
|
return message
|
||||||
|
|
||||||
def dump_request_data(data, event="create/order"):
|
def dump_request_data(data, event="create/order"):
|
||||||
event_mapper = {
|
event_mapper = {
|
||||||
"orders/create": get_webhook_address(connector_name='shopify_connection', method="sync_sales_order", exclude_uri=True),
|
"orders/create": get_webhook_address(connector_name='shopify_connection', method="sync_sales_order", exclude_uri=True),
|
||||||
@ -43,11 +58,11 @@ def dump_request_data(data, event="create/order"):
|
|||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
frappe.db.commit()
|
frappe.db.commit()
|
||||||
frappe.enqueue(method=event_mapper[event], queue='short', timeout=300, is_async=True,
|
frappe.enqueue(method=event_mapper[event], queue='short', timeout=300, is_async=True,
|
||||||
**{"order": data, "request_id": log.name})
|
**{"order": data, "request_id": log.name})
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def resync(method, name, request_data):
|
def resync(method, name, request_data):
|
||||||
frappe.db.set_value("Shopify Log", name, "status", "Queued", update_modified=False)
|
frappe.db.set_value("Shopify Log", name, "status", "Queued", update_modified=False)
|
||||||
frappe.enqueue(method=method, queue='short', timeout=300, is_async=True,
|
frappe.enqueue(method=method, queue='short', timeout=300, is_async=True,
|
||||||
**{"order": json.loads(request_data), "request_id": name})
|
**{"order": json.loads(request_data), "request_id": name})
|
||||||
|
@ -30,13 +30,9 @@ class ShopifySettings(Document):
|
|||||||
# url = get_shopify_url('admin/webhooks.json', self)
|
# url = get_shopify_url('admin/webhooks.json', self)
|
||||||
created_webhooks = [d.method for d in self.webhooks]
|
created_webhooks = [d.method for d in self.webhooks]
|
||||||
url = get_shopify_url('admin/api/2019-04/webhooks.json', self)
|
url = get_shopify_url('admin/api/2019-04/webhooks.json', self)
|
||||||
print('url', url)
|
|
||||||
for method in webhooks:
|
for method in webhooks:
|
||||||
print('method', method)
|
|
||||||
session = get_request_session()
|
session = get_request_session()
|
||||||
print('session', session)
|
|
||||||
try:
|
try:
|
||||||
print(get_header(self))
|
|
||||||
d = session.post(url, data=json.dumps({
|
d = session.post(url, data=json.dumps({
|
||||||
"webhook": {
|
"webhook": {
|
||||||
"topic": method,
|
"topic": method,
|
||||||
@ -44,7 +40,6 @@ class ShopifySettings(Document):
|
|||||||
"format": "json"
|
"format": "json"
|
||||||
}
|
}
|
||||||
}), headers=get_header(self))
|
}), headers=get_header(self))
|
||||||
print('d', d.json())
|
|
||||||
d.raise_for_status()
|
d.raise_for_status()
|
||||||
self.update_webhook_table(method, d.json())
|
self.update_webhook_table(method, d.json())
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -67,7 +62,6 @@ class ShopifySettings(Document):
|
|||||||
self.remove(d)
|
self.remove(d)
|
||||||
|
|
||||||
def update_webhook_table(self, method, res):
|
def update_webhook_table(self, method, res):
|
||||||
print('update')
|
|
||||||
self.append("webhooks", {
|
self.append("webhooks", {
|
||||||
"webhook_id": res['webhook']['id'],
|
"webhook_id": res['webhook']['id'],
|
||||||
"method": method
|
"method": method
|
||||||
@ -75,7 +69,6 @@ class ShopifySettings(Document):
|
|||||||
|
|
||||||
def get_shopify_url(path, settings):
|
def get_shopify_url(path, settings):
|
||||||
if settings.app_type == "Private":
|
if settings.app_type == "Private":
|
||||||
print(settings.api_key, settings.get_password('password'), settings.shopify_url, path)
|
|
||||||
return 'https://{}:{}@{}/{}'.format(settings.api_key, settings.get_password('password'), settings.shopify_url, path)
|
return 'https://{}:{}@{}/{}'.format(settings.api_key, settings.get_password('password'), settings.shopify_url, path)
|
||||||
else:
|
else:
|
||||||
return 'https://{}/{}'.format(settings.shopify_url, path)
|
return 'https://{}/{}'.format(settings.shopify_url, path)
|
||||||
|
@ -35,7 +35,8 @@ class BOM(WebsiteGenerator):
|
|||||||
# name can be BOM/ITEM/001, BOM/ITEM/001-1, BOM-ITEM-001, BOM-ITEM-001-1
|
# name can be BOM/ITEM/001, BOM/ITEM/001-1, BOM-ITEM-001, BOM-ITEM-001-1
|
||||||
|
|
||||||
# split by item
|
# split by item
|
||||||
names = [name.split(self.item)[-1][1:] for name in names]
|
names = [name.split(self.item, 1) for name in names]
|
||||||
|
names = [d[-1][1:] for d in filter(lambda x: len(x) > 1 and x[-1], names)]
|
||||||
|
|
||||||
# split by (-) if cancelled
|
# split by (-) if cancelled
|
||||||
names = [cint(name.split('-')[-1]) for name in names]
|
names = [cint(name.split('-')[-1]) for name in names]
|
||||||
|
@ -682,10 +682,10 @@
|
|||||||
"label": "Additional Discount and Coupon Code"
|
"label": "Additional Discount and Coupon Code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "coupon_code",
|
"fieldname": "coupon_code",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Coupon Code",
|
"label": "Coupon Code",
|
||||||
"options": "Coupon Code"
|
"options": "Coupon Code"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": "Grand Total",
|
"default": "Grand Total",
|
||||||
@ -1185,6 +1185,7 @@
|
|||||||
"default": "0",
|
"default": "0",
|
||||||
"fieldname": "skip_delivery_note",
|
"fieldname": "skip_delivery_note",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"hidden": 1,
|
||||||
"label": "Skip Delivery Note",
|
"label": "Skip Delivery Note",
|
||||||
"print_hide": 1
|
"print_hide": 1
|
||||||
}
|
}
|
||||||
@ -1192,7 +1193,7 @@
|
|||||||
"icon": "fa fa-file-text",
|
"icon": "fa fa-file-text",
|
||||||
"idx": 105,
|
"idx": 105,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2019-10-14 08:46:07.540565",
|
"modified": "2019-10-22 14:26:42.767189",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order",
|
"name": "Sales Order",
|
||||||
@ -1269,4 +1270,4 @@
|
|||||||
"title_field": "title",
|
"title_field": "title",
|
||||||
"track_changes": 1,
|
"track_changes": 1,
|
||||||
"track_seen": 1
|
"track_seen": 1
|
||||||
}
|
}
|
@ -329,8 +329,8 @@ class StockEntry(StockController):
|
|||||||
if total_completed_qty > flt(completed_qty):
|
if total_completed_qty > flt(completed_qty):
|
||||||
job_card = frappe.db.get_value('Job Card', {'operation_id': d.name}, 'name')
|
job_card = frappe.db.get_value('Job Card', {'operation_id': d.name}, 'name')
|
||||||
if not job_card:
|
if not job_card:
|
||||||
frappe.throw(_("Work Order {0}: job card not found for the operation {1}")
|
frappe.throw(_("Work Order {0}: Job Card not found for the operation {1}")
|
||||||
.format(self.work_order, job_card))
|
.format(self.work_order, d.operation))
|
||||||
|
|
||||||
work_order_link = frappe.utils.get_link_to_form('Work Order', self.work_order)
|
work_order_link = frappe.utils.get_link_to_form('Work Order', self.work_order)
|
||||||
job_card_link = frappe.utils.get_link_to_form('Job Card', job_card)
|
job_card_link = frappe.utils.get_link_to_form('Job Card', job_card)
|
||||||
|
@ -30,7 +30,7 @@ def get_total_stock(filters):
|
|||||||
|
|
||||||
if filters.get("group_by") == "Warehouse":
|
if filters.get("group_by") == "Warehouse":
|
||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
conditions += " AND warehouse.company = '%s'" % frappe.db.escape(filters.get("company"), percent=False)
|
conditions += " AND warehouse.company = %s" % frappe.db.escape(filters.get("company"), percent=False)
|
||||||
|
|
||||||
conditions += " GROUP BY ledger.warehouse, item.item_code"
|
conditions += " GROUP BY ledger.warehouse, item.item_code"
|
||||||
columns += "'' as company, ledger.warehouse"
|
columns += "'' as company, ledger.warehouse"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user