fix: woocommerce settings patch

This commit is contained in:
Saurabh
2019-04-16 15:57:21 +05:30
parent 332b4171c0
commit 7df8c0ef82

View File

@@ -1,10 +1,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cint
def execute(): def execute():
woocommerce_setting_enable_sync = frappe.db.sql("SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'enable_sync'", as_dict=True) frappe.reload_doc("erpnext_integrations", "doctype","woocommerce_settings")
if len(woocommerce_setting_enable_sync) and woocommerce_setting_enable_sync[0].value == '1': doc = frappe.get_doc("Woocommerce Settings")
frappe.db.sql("""UPDATE tabSingles
SET value = (SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'modified_by') if cint(doc.enable_sync):
WHERE doctype = 'Woocommerce Settings' doc.creation_user = doc.modified_by
AND field = 'creation_user';""") doc.save(ignore_permissions=True)