fix: fix creating documents from sales invoice (#45346)

Co-authored-by: Meike Nedwidek <nedwidek@kk-software.de>
This commit is contained in:
meike289
2025-01-23 13:24:00 +01:00
committed by GitHub
parent 85b6fdd067
commit 1758e125e0

View File

@@ -16,6 +16,10 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
setup(doc) { setup(doc) {
this.setup_posting_date_time_check(); this.setup_posting_date_time_check();
super.setup(doc); super.setup(doc);
this.frm.make_methods = {
Dunning: this.make_dunning.bind(this),
"Invoice Discounting": this.make_invoice_discounting.bind(this),
};
} }
company() { company() {
super.company(); super.company();
@@ -125,12 +129,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
}, },
__("Create") __("Create")
); );
this.frm.add_custom_button( this.frm.add_custom_button(
__("Invoice Discounting"), __("Invoice Discounting"),
function () { this.make_invoice_discounting.bind(this),
this.frm.events.create_invoice_discounting(this.frm);
},
__("Create") __("Create")
); );
@@ -139,22 +140,14 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
.reduce((prev, current) => prev || current, false); .reduce((prev, current) => prev || current, false);
if (payment_is_overdue) { if (payment_is_overdue) {
this.frm.add_custom_button( this.frm.add_custom_button(__("Dunning"), this.make_dunning.bind(this), __("Create"));
__("Dunning"),
() => {
this.frm.events.create_dunning(this.frm);
},
__("Create")
);
} }
} }
if (doc.docstatus === 1) { if (doc.docstatus === 1) {
this.frm.add_custom_button( this.frm.add_custom_button(
__("Maintenance Schedule"), __("Maintenance Schedule"),
function () { this.make_maintenance_schedule.bind(this),
this.frm.cscript.make_maintenance_schedule();
},
__("Create") __("Create")
); );
} }
@@ -189,6 +182,20 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends (
erpnext.accounts.unreconcile_payment.add_unreconcile_btn(me.frm); erpnext.accounts.unreconcile_payment.add_unreconcile_btn(me.frm);
} }
make_invoice_discounting() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
frm: this.frm,
});
}
make_dunning() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
frm: this.frm,
});
}
make_maintenance_schedule() { make_maintenance_schedule() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule", method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
@@ -1044,20 +1051,6 @@ frappe.ui.form.on("Sales Invoice", {
frm.set_df_property("return_against", "label", __("Adjustment Against")); frm.set_df_property("return_against", "label", __("Adjustment Against"));
} }
}, },
create_invoice_discounting: function (frm) {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
frm: frm,
});
},
create_dunning: function (frm) {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_dunning",
frm: frm,
});
},
}); });
frappe.ui.form.on("Sales Invoice Timesheet", { frappe.ui.form.on("Sales Invoice Timesheet", {