fix: un-using buggy JS frappe.new_doc

This commit is contained in:
Gavin D'souza 2020-05-02 18:58:33 +05:30
parent af612ddb6d
commit 0c353a64a4
2 changed files with 27 additions and 3 deletions

View File

@ -253,10 +253,24 @@ erpnext.tally_migration.resolve = (document) => {
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 @@ erpnext.tally_migration.get_html_rows = (logs, field) => {
</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>`

View File

@ -28,6 +28,16 @@ PRIMARY_ACCOUNT = "Primary"
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)