fix: set doctype and name in docinfo (#18088)

This commit is contained in:
Sagar Vora 2022-09-12 08:48:20 +00:00 committed by GitHub
parent 2866069eb4
commit 627302d851
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View file

@ -110,6 +110,8 @@ def get_docinfo(doc=None, doctype=None, name=None):
docinfo.update(
{
"doctype": doc.doctype,
"name": doc.name,
"attachments": get_attachments(doc.doctype, doc.name),
"communications": communications_except_auto_messages,
"automated_messages": automated_messages,

View file

@ -56,16 +56,11 @@ Object.assign(frappe.model, {
sync_docinfo: (r) => {
// set docinfo (comments, assign, attachments)
if (r.docinfo) {
var doc;
if (r.docs) {
doc = r.docs[0];
} else {
if (cur_frm) doc = cur_frm.doc;
}
if (doc) {
if (!frappe.model.docinfo[doc.doctype]) frappe.model.docinfo[doc.doctype] = {};
frappe.model.docinfo[doc.doctype][doc.name] = r.docinfo;
const { doctype, name } = r.docinfo;
if (!frappe.model.docinfo[doctype]) {
frappe.model.docinfo[doctype] = {};
}
frappe.model.docinfo[doctype][name] = r.docinfo;
// copy values to frappe.boot.user_info
Object.assign(frappe.boot.user_info, r.docinfo.user_info);