2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 12:10:06 +00:00

feat: Allow default to be a function

This commit is contained in:
Rushabh Mehta 2020-05-06 23:28:36 +05:30
parent 8158dade1d
commit 613e5d6a5f

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;