2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00

fix: Add loadLink method to document

This commit is contained in:
Faris Ansari 2019-11-28 23:09:20 +05:30
parent f6204ad6db
commit ab51ce3122

View File

@ -229,6 +229,13 @@ module.exports = class BaseDocument extends Observable {
this._links = {};
let inlineLinks = this.meta.fields.filter(df => df.inline);
for (let df of inlineLinks) {
await this.loadLink(df.fieldname);
}
}
async loadLink(fieldname) {
this._links = this._links || {};
let df = this.meta.getField(fieldname);
if (this[df.fieldname]) {
this._links[df.fieldname] = await frappe.getDoc(
df.target,
@ -236,7 +243,6 @@ module.exports = class BaseDocument extends Observable {
);
}
}
}
getLink(fieldname) {
return this._links ? this._links[fieldname] : null;