mirror of
https://github.com/frappe/books.git
synced 2024-11-13 00:46:28 +00:00
fix: update modified after triggers
This commit is contained in:
parent
2205a212eb
commit
75184d43c3
@ -224,11 +224,11 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
setStandardValues() {
|
setStandardValues() {
|
||||||
// set standard values on server-side only
|
// set standard values on server-side only
|
||||||
if (frappe.isServer) {
|
if (frappe.isServer) {
|
||||||
let now = new Date().toISOString();
|
if (this.isSubmittable && this.submitted == null) {
|
||||||
if (!this.submitted) {
|
|
||||||
this.submitted = 0;
|
this.submitted = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let now = new Date().toISOString();
|
||||||
if (!this.owner) {
|
if (!this.owner) {
|
||||||
this.owner = frappe.session.user;
|
this.owner = frappe.session.user;
|
||||||
}
|
}
|
||||||
@ -237,9 +237,14 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
this.creation = now;
|
this.creation = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.modifiedBy) {
|
this.updateModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateModified() {
|
||||||
|
if (frappe.isServer) {
|
||||||
|
let now = new Date().toISOString();
|
||||||
this.modifiedBy = frappe.session.user;
|
this.modifiedBy = frappe.session.user;
|
||||||
}
|
|
||||||
this.modified = now;
|
this.modified = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,7 +470,6 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
|
|
||||||
async commit() {
|
async commit() {
|
||||||
// re-run triggers
|
// re-run triggers
|
||||||
this.setStandardValues();
|
|
||||||
this.setKeywords();
|
this.setKeywords();
|
||||||
this.setChildIdx();
|
this.setChildIdx();
|
||||||
await this.applyFormula();
|
await this.applyFormula();
|
||||||
@ -474,6 +478,7 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
|
|
||||||
async insert() {
|
async insert() {
|
||||||
await this.setName();
|
await this.setName();
|
||||||
|
this.setStandardValues();
|
||||||
await this.commit();
|
await this.commit();
|
||||||
await this.validateInsert();
|
await this.validateInsert();
|
||||||
await this.trigger('beforeInsert');
|
await this.trigger('beforeInsert');
|
||||||
@ -501,6 +506,9 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
if (this.flags.submitAction) await this.trigger('beforeSubmit');
|
if (this.flags.submitAction) await this.trigger('beforeSubmit');
|
||||||
if (this.flags.revertAction) await this.trigger('beforeRevert');
|
if (this.flags.revertAction) await this.trigger('beforeRevert');
|
||||||
|
|
||||||
|
// update modifiedBy and modified
|
||||||
|
this.updateModified();
|
||||||
|
|
||||||
const data = await frappe.db.update(this.doctype, this.getValidDict());
|
const data = await frappe.db.update(this.doctype, this.getValidDict());
|
||||||
this.syncValues(data);
|
this.syncValues(data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user