2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

Merge pull request #116 from rmehta/default-as-function

This commit is contained in:
Faris Ansari 2020-05-06 23:36:11 +05:30 committed by GitHub
commit 3978e79863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,8 +111,12 @@ module.exports = class BaseDocument extends Observable {
defaultValue = [];
}
if (field.default) {
if (typeof field.default === 'function') {
defaultValue = field.default(this);
} else {
defaultValue = field.default;
}
}
this[field.fieldname] = defaultValue;
}