2018-02-07 22:14:59 +05:30
|
|
|
const frappe = require('frappejs');
|
|
|
|
|
2018-01-12 17:55:07 +05:30
|
|
|
module.exports = {
|
2018-02-07 22:14:59 +05:30
|
|
|
async get_series_next(prefix) {
|
|
|
|
let series;
|
|
|
|
try {
|
|
|
|
series = await frappe.get_doc('Number Series', prefix);
|
|
|
|
} catch (e) {
|
|
|
|
if (!e.status_code || e.status_code !== 404) {
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
series = frappe.new_doc({doctype: 'Number Series', name: prefix, current: 0});
|
|
|
|
await series.insert();
|
|
|
|
}
|
|
|
|
let next = await series.next()
|
|
|
|
return prefix + next;
|
|
|
|
},
|
2018-01-31 18:34:46 +05:30
|
|
|
common_fields: [
|
2018-01-12 17:55:07 +05:30
|
|
|
{
|
|
|
|
fieldname: 'name', fieldtype: 'Data', reqd: 1
|
2018-01-31 18:26:21 +05:30
|
|
|
}
|
2018-01-31 18:34:46 +05:30
|
|
|
],
|
2018-01-31 18:26:21 +05:30
|
|
|
parent_fields: [
|
2018-01-12 17:55:07 +05:30
|
|
|
{
|
|
|
|
fieldname: 'owner', fieldtype: 'Link', reqd: 1, options: 'User'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'modified_by', fieldtype: 'Link', reqd: 1, options: 'User'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'creation', fieldtype: 'Datetime', reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'modified', fieldtype: 'Datetime', reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'keywords', fieldtype: 'Text'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'docstatus', fieldtype: 'Int', reqd: 1, default: 0
|
|
|
|
}
|
|
|
|
],
|
|
|
|
child_fields: [
|
|
|
|
{
|
|
|
|
fieldname: 'idx', fieldtype: 'Int', reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'parent', fieldtype: 'Data', reqd: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'parenttype', fieldtype: 'Link', reqd: 1, options: 'DocType'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fieldname: 'parentfield', fieldtype: 'Data', reqd: 1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|