mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: doc.setName
This commit is contained in:
parent
26f0a720e2
commit
88c84e805b
2
index.js
2
index.js
@ -214,7 +214,7 @@ module.exports = {
|
||||
async getNewDoc(doctype) {
|
||||
let doc = this.newDoc({ doctype: doctype });
|
||||
doc._notInserted = true;
|
||||
doc.name = this.getRandomString();
|
||||
await doc.setName();
|
||||
this.addToCache(doc);
|
||||
return doc;
|
||||
},
|
||||
|
@ -337,6 +337,10 @@ module.exports = class BaseDocument extends Observable {
|
||||
}
|
||||
}
|
||||
|
||||
async setName() {
|
||||
await naming.setName(this);
|
||||
}
|
||||
|
||||
async commit() {
|
||||
// re-run triggers
|
||||
this.setStandardValues();
|
||||
@ -347,7 +351,7 @@ module.exports = class BaseDocument extends Observable {
|
||||
}
|
||||
|
||||
async insert() {
|
||||
await naming.setName(this);
|
||||
await this.setName();
|
||||
await this.commit();
|
||||
await this.trigger('beforeInsert');
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
const frappe = require('frappejs');
|
||||
const { getRandomString } = require('frappejs/utils');
|
||||
|
||||
module.exports = {
|
||||
async setName(doc) {
|
||||
@ -30,7 +31,7 @@ module.exports = {
|
||||
// assign a random name by default
|
||||
// override doc to set a name
|
||||
if (!doc.name) {
|
||||
doc.name = frappe.getRandomString();
|
||||
doc.name = getRandomString();
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user