mirror of
https://github.com/frappe/books.git
synced 2025-01-12 02:59:11 +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) {
|
async getNewDoc(doctype) {
|
||||||
let doc = this.newDoc({ doctype: doctype });
|
let doc = this.newDoc({ doctype: doctype });
|
||||||
doc._notInserted = true;
|
doc._notInserted = true;
|
||||||
doc.name = this.getRandomString();
|
await doc.setName();
|
||||||
this.addToCache(doc);
|
this.addToCache(doc);
|
||||||
return doc;
|
return doc;
|
||||||
},
|
},
|
||||||
|
@ -337,6 +337,10 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async setName() {
|
||||||
|
await naming.setName(this);
|
||||||
|
}
|
||||||
|
|
||||||
async commit() {
|
async commit() {
|
||||||
// re-run triggers
|
// re-run triggers
|
||||||
this.setStandardValues();
|
this.setStandardValues();
|
||||||
@ -347,7 +351,7 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async insert() {
|
async insert() {
|
||||||
await naming.setName(this);
|
await this.setName();
|
||||||
await this.commit();
|
await this.commit();
|
||||||
await this.trigger('beforeInsert');
|
await this.trigger('beforeInsert');
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const frappe = require('frappejs');
|
const frappe = require('frappejs');
|
||||||
|
const { getRandomString } = require('frappejs/utils');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
async setName(doc) {
|
async setName(doc) {
|
||||||
@ -30,7 +31,7 @@ module.exports = {
|
|||||||
// assign a random name by default
|
// assign a random name by default
|
||||||
// override doc to set a name
|
// override doc to set a name
|
||||||
if (!doc.name) {
|
if (!doc.name) {
|
||||||
doc.name = frappe.getRandomString();
|
doc.name = getRandomString();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user