fix: don't create debit/credit note automatically (#19185)
This commit is contained in:
parent
5ef26b42a8
commit
3564ac7c88
@ -85,26 +85,13 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
frm.add_custom_button(__('Credit Note'), function() {
|
frm.add_custom_button(__('Credit Note'), function() {
|
||||||
frappe.confirm(__("Are you sure you want to make credit note?"),
|
frappe.model.open_mapped_doc({
|
||||||
function() {
|
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
|
||||||
frm.trigger("make_credit_note");
|
frm: cur_frm,
|
||||||
}
|
})
|
||||||
);
|
|
||||||
}, __('Create'));
|
}, __('Create'));
|
||||||
|
|
||||||
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
make_credit_note: function(frm) {
|
|
||||||
frm.call({
|
|
||||||
method: "make_return_invoice",
|
|
||||||
doc: frm.doc,
|
|
||||||
freeze: true,
|
|
||||||
callback: function() {
|
|
||||||
frm.reload_doc();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -458,6 +458,9 @@ def make_sales_invoice(source_name, target_doc=None):
|
|||||||
doc = get_mapped_doc("Delivery Note", source_name, {
|
doc = get_mapped_doc("Delivery Note", source_name, {
|
||||||
"Delivery Note": {
|
"Delivery Note": {
|
||||||
"doctype": "Sales Invoice",
|
"doctype": "Sales Invoice",
|
||||||
|
"field_map": {
|
||||||
|
"is_return": "is_return"
|
||||||
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"docstatus": ["=", 1]
|
"docstatus": ["=", 1]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,28 +41,15 @@ frappe.ui.form.on("Purchase Receipt", {
|
|||||||
|
|
||||||
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
frm.add_custom_button(__('Debit Note'), function() {
|
frm.add_custom_button(__('Debit Note'), function() {
|
||||||
frappe.confirm(__("Are you sure you want to make debit note?"),
|
frappe.model.open_mapped_doc({
|
||||||
function() {
|
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
|
||||||
frm.trigger("make_debit_note");
|
frm: cur_frm,
|
||||||
}
|
})
|
||||||
);
|
|
||||||
}, __('Create'));
|
}, __('Create'));
|
||||||
|
|
||||||
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
make_debit_note: function(frm) {
|
|
||||||
frm.call({
|
|
||||||
method: "make_return_invoice",
|
|
||||||
doc: frm.doc,
|
|
||||||
freeze: true,
|
|
||||||
callback: function() {
|
|
||||||
frm.reload_doc();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
frm.trigger("toggle_display_account_head");
|
frm.trigger("toggle_display_account_head");
|
||||||
},
|
},
|
||||||
|
|||||||
@ -426,16 +426,6 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
self.load_from_db()
|
self.load_from_db()
|
||||||
|
|
||||||
def make_return_invoice(self):
|
|
||||||
return_invoice = make_purchase_invoice(self.name)
|
|
||||||
return_invoice.is_return = True
|
|
||||||
return_invoice.save()
|
|
||||||
return_invoice.submit()
|
|
||||||
|
|
||||||
debit_note_link = frappe.utils.get_link_to_form('Purchase Invoice', return_invoice.name)
|
|
||||||
|
|
||||||
frappe.msgprint(_("Debit Note {0} has been created automatically").format(debit_note_link))
|
|
||||||
|
|
||||||
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
||||||
# Billed against Sales Order directly
|
# Billed against Sales Order directly
|
||||||
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
||||||
@ -510,7 +500,8 @@ def make_purchase_invoice(source_name, target_doc=None):
|
|||||||
"Purchase Receipt": {
|
"Purchase Receipt": {
|
||||||
"doctype": "Purchase Invoice",
|
"doctype": "Purchase Invoice",
|
||||||
"field_map": {
|
"field_map": {
|
||||||
"supplier_warehouse":"supplier_warehouse"
|
"supplier_warehouse":"supplier_warehouse",
|
||||||
|
"is_return": "is_return"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"docstatus": ["=", 1],
|
"docstatus": ["=", 1],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user