mirror of
https://github.com/frappe/books.git
synced 2024-12-25 04:06:04 +00:00
feat: Rename methods
This commit is contained in:
parent
e0c6a1a411
commit
700ee9c55c
@ -299,6 +299,10 @@ module.exports = class Database extends Observable {
|
||||
// await frappe.db.run('delete from SingleValue where parent=?', name)
|
||||
}
|
||||
|
||||
async rename(doctype, oldName, newName) {
|
||||
// await frappe.db.run('update doctype set name = ? where name = ?', name)
|
||||
}
|
||||
|
||||
prepareChild(parenttype, parent, child, field, idx) {
|
||||
if (!child.name) {
|
||||
child.name = frappe.getRandomString();
|
||||
|
@ -159,6 +159,11 @@ module.exports = class sqliteDatabase extends Database {
|
||||
await frappe.db.run('delete from SingleValue where parent=?', name)
|
||||
}
|
||||
|
||||
async rename(doctype, oldName, newName) {
|
||||
await frappe.db.run(`update ${baseDoctype} set name = ? where name = ?`, [newName, oldName]);
|
||||
await frappe.db.commit();
|
||||
}
|
||||
|
||||
async setValues(doctype, name, fieldValuePair) {
|
||||
const meta = frappe.getMeta(doctype);
|
||||
const validFields = this.getKeys(doctype);
|
||||
|
@ -346,6 +346,13 @@ module.exports = class BaseDocument extends Observable {
|
||||
this.update();
|
||||
}
|
||||
|
||||
async rename(newName) {
|
||||
await this.trigger('beforeRename');
|
||||
await frappe.db.rename(this.doctype, this.name, newName);
|
||||
this.name = newName;
|
||||
await this.trigger('afterRename');
|
||||
}
|
||||
|
||||
// trigger methods on the class if they match
|
||||
// with the trigger name
|
||||
async trigger(event, params) {
|
||||
|
Loading…
Reference in New Issue
Block a user