Merge pull request #23701 from pps190/fix-grid-defaults

This commit is contained in:
Raffael Meyer 2024-02-14 18:41:23 +01:00 committed by GitHub
commit f9b5d60ec9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -834,7 +834,11 @@ export default class Grid {
if (!this.df.data) {
this.df.data = this.get_data() || [];
}
this.df.data.push({ idx: this.df.data.length + 1, __islocal: true });
const defaults = this.docfields.reduce((acc, d) => {
acc[d.fieldname] = d.default;
return acc;
}, {});
this.df.data.push({ idx: this.df.data.length + 1, __islocal: true, ...defaults });
this.refresh();
}