2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
This commit is contained in:
Faris Ansari 2020-05-06 23:48:27 +05:30
commit 80dd922e15

View File

@ -111,7 +111,11 @@ module.exports = class BaseDocument extends Observable {
defaultValue = [];
}
if (field.default) {
defaultValue = field.default;
if (typeof field.default === 'function') {
defaultValue = field.default(this);
} else {
defaultValue = field.default;
}
}
this[field.fieldname] = defaultValue;
@ -432,7 +436,7 @@ module.exports = class BaseDocument extends Observable {
.getFormulaFields();
if (formulaFields.length) {
// for each row
for (let row of this[tablefield.fieldname]) {
for (let row of this[tablefield.fieldname] || []) {
for (let field of formulaFields) {
if (shouldApplyFormula(field, row)) {
let val = await this.getValueFromFormula(field, row);