mirror of
https://github.com/frappe/books.git
synced 2024-11-10 15:50:56 +00:00
fix: Add loadLink method to document
This commit is contained in:
parent
f6204ad6db
commit
ab51ce3122
@ -229,6 +229,13 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
this._links = {};
|
this._links = {};
|
||||||
let inlineLinks = this.meta.fields.filter(df => df.inline);
|
let inlineLinks = this.meta.fields.filter(df => df.inline);
|
||||||
for (let df of inlineLinks) {
|
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]) {
|
if (this[df.fieldname]) {
|
||||||
this._links[df.fieldname] = await frappe.getDoc(
|
this._links[df.fieldname] = await frappe.getDoc(
|
||||||
df.target,
|
df.target,
|
||||||
@ -236,7 +243,6 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getLink(fieldname) {
|
getLink(fieldname) {
|
||||||
return this._links ? this._links[fieldname] : null;
|
return this._links ? this._links[fieldname] : null;
|
||||||
|
Loading…
Reference in New Issue
Block a user