perf: improve mapping function speed

This commit is contained in:
Mangesh-Khairnar 2019-05-03 21:19:59 +05:30
parent 48d88b0478
commit e56eaf6364

View File

@ -14,7 +14,6 @@ from frappe.integrations.utils import get_payment_gateway_controller
from frappe.utils.background_jobs import enqueue from frappe.utils.background_jobs import enqueue
from erpnext.erpnext_integrations.stripe_integration import create_stripe_subscription from erpnext.erpnext_integrations.stripe_integration import create_stripe_subscription
from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate from erpnext.accounts.doctype.subscription_plan.subscription_plan import get_plan_rate
from frappe.model.mapper import get_mapped_doc
class PaymentRequest(Document): class PaymentRequest(Document):
def validate(self): def validate(self):
@ -426,6 +425,7 @@ def get_subscription_details(reference_doctype, reference_name):
@frappe.whitelist() @frappe.whitelist()
def make_payment_order(source_name, target_doc=None): def make_payment_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target): def set_missing_values(source, target):
target.append('references', { target.append('references', {
'reference_doctype': source.reference_doctype, 'reference_doctype': source.reference_doctype,
@ -444,4 +444,4 @@ def make_payment_order(source_name, target_doc=None):
} }
}, target_doc, set_missing_values) }, target_doc, set_missing_values)
return doclist return doclist