mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: Remove doc from cache if name changes
This commit is contained in:
parent
94cc020f5a
commit
f1823a71ab
8
index.js
8
index.js
@ -135,6 +135,14 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
removeFromCache(doctype, name) {
|
||||
try {
|
||||
delete this.docs[doctype][name];
|
||||
} catch(e) {
|
||||
console.warn(`Document ${doctype} ${name} does not exist`);
|
||||
}
|
||||
},
|
||||
|
||||
isDirty(doctype, name) {
|
||||
return (
|
||||
(this.docs &&
|
||||
|
@ -331,9 +331,14 @@ module.exports = class BaseDocument extends Observable {
|
||||
await this.commit();
|
||||
await this.trigger('beforeInsert');
|
||||
|
||||
let oldName = this.name;
|
||||
const data = await frappe.db.insert(this.doctype, this.getValidDict());
|
||||
this.syncValues(data);
|
||||
|
||||
if (oldName !== this.name) {
|
||||
frappe.removeFromCache(this.doctype, oldName);
|
||||
}
|
||||
|
||||
await this.trigger('afterInsert');
|
||||
await this.trigger('afterSave');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user