Merge pull request #19758 from hrwX/new_invoice_fix
fix(Project): add project in child for items
This commit is contained in:
commit
dda1ef6b13
@ -4,20 +4,16 @@ frappe.ui.form.on("Project", {
|
|||||||
setup(frm) {
|
setup(frm) {
|
||||||
frm.make_methods = {
|
frm.make_methods = {
|
||||||
'Timesheet': () => {
|
'Timesheet': () => {
|
||||||
let doctype = 'Timesheet';
|
open_form(frm, "Timesheet", "Timesheet Detail", "time_logs");
|
||||||
frappe.model.with_doctype(doctype, () => {
|
},
|
||||||
let new_doc = frappe.model.get_new_doc(doctype);
|
'Purchase Order': () => {
|
||||||
|
open_form(frm, "Purchase Order", "Purchase Order Item", "items");
|
||||||
// add a new row and set the project
|
},
|
||||||
let time_log = frappe.model.get_new_doc('Timesheet Detail');
|
'Purchase Receipt': () => {
|
||||||
time_log.project = frm.doc.name;
|
open_form(frm, "Purchase Receipt", "Purchase Receipt Item", "items");
|
||||||
time_log.parent = new_doc.name;
|
},
|
||||||
time_log.parentfield = 'time_logs';
|
'Purchase Invoice': () => {
|
||||||
time_log.parenttype = 'Timesheet';
|
open_form(frm, "Purchase Invoice", "Purchase Invoice Item", "items");
|
||||||
new_doc.time_logs = [time_log];
|
|
||||||
|
|
||||||
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -123,3 +119,20 @@ frappe.ui.form.on("Project", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function open_form(frm, doctype, child_doctype, parentfield) {
|
||||||
|
frappe.model.with_doctype(doctype, () => {
|
||||||
|
let new_doc = frappe.model.get_new_doc(doctype);
|
||||||
|
|
||||||
|
// add a new row and set the project
|
||||||
|
let new_child_doc = frappe.model.get_new_doc(child_doctype);
|
||||||
|
new_child_doc.project = frm.doc.name;
|
||||||
|
new_child_doc.parent = new_doc.name;
|
||||||
|
new_child_doc.parentfield = parentfield;
|
||||||
|
new_child_doc.parenttype = doctype;
|
||||||
|
new_doc[parentfield] = [new_child_doc];
|
||||||
|
|
||||||
|
frappe.ui.form.make_quick_entry(doctype, null, null, new_doc);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user