fix: un-using buggy JS frappe.new_doc
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
index d9811b5..fd16d1e 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
@@ -253,10 +253,24 @@
frm.save();
}
-erpnext.tally_migration.create_new_doc = (doctype, document) => {
+erpnext.tally_migration.create_new_doc = (document) => {
/* Mark as resolved and create new document */
erpnext.tally_migration.resolve(document);
- frappe.new_doc(doctype, document);
+ return frappe.call({
+ type: "POST",
+ method: 'erpnext.erpnext_integrations.doctype.tally_migration.tally_migration.new_doc',
+ args: {
+ document
+ },
+ freeze: true,
+ callback: function(r) {
+ if(!r.exc) {
+ frappe.model.sync(r.message);
+ frappe.get_doc(r.message.doctype, r.message.name).__run_link_triggers = true;
+ frappe.set_route("Form", r.message.doctype, r.message.name);
+ }
+ }
+ });
}
erpnext.tally_migration.get_html_rows = (logs, field) => {
@@ -290,7 +304,7 @@
</div>`;
let create_button = `
- <button class='btn btn-default btn-xs m-3' type='button' onclick='erpnext.tally_migration.create_new_doc("${doc.doctype}", ${JSON.stringify(doc)})'>
+ <button class='btn btn-default btn-xs m-3' type='button' onclick='erpnext.tally_migration.create_new_doc(${JSON.stringify(doc)})'>
${__("Create Document")}
</button>`
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
index 393c5d4..d9c5852 100644
--- a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
@@ -28,6 +28,16 @@
VOUCHER_CHUNK_SIZE = 500
+@frappe.whitelist()
+def new_doc(document):
+ document = json.loads(document)
+ doctype = document.pop("doctype")
+ document.pop("name", None)
+ doc = frappe.new_doc(doctype)
+ doc.update(document)
+
+ return doc
+
class TallyMigration(Document):
def validate(self):
failed_import_log = json.loads(self.failed_import_log)