2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +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,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;