fix: don't create debit/credit note automatically (#19185)

This commit is contained in:
Rucha Mahabal 2019-09-30 10:59:28 +05:30 committed by Nabin Hait
parent 5ef26b42a8
commit 3564ac7c88
4 changed files with 13 additions and 45 deletions

View File

@ -85,26 +85,13 @@ frappe.ui.form.on("Delivery Note", {
refresh: function(frm) {
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
frm.add_custom_button(__('Credit Note'), function() {
frappe.confirm(__("Are you sure you want to make credit note?"),
function() {
frm.trigger("make_credit_note");
}
);
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
frm: cur_frm,
})
}, __('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();
}
});
}
});

View File

@ -458,6 +458,9 @@ def make_sales_invoice(source_name, target_doc=None):
doc = get_mapped_doc("Delivery Note", source_name, {
"Delivery Note": {
"doctype": "Sales Invoice",
"field_map": {
"is_return": "is_return"
},
"validation": {
"docstatus": ["=", 1]
}

View File

@ -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) {
frm.add_custom_button(__('Debit Note'), function() {
frappe.confirm(__("Are you sure you want to make debit note?"),
function() {
frm.trigger("make_debit_note");
}
);
frappe.model.open_mapped_doc({
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
frm: cur_frm,
})
}, __('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) {
frm.trigger("toggle_display_account_head");
},

View File

@ -426,16 +426,6 @@ class PurchaseReceipt(BuyingController):
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):
# Billed against Sales Order directly
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": {
"doctype": "Purchase Invoice",
"field_map": {
"supplier_warehouse":"supplier_warehouse"
"supplier_warehouse":"supplier_warehouse",
"is_return": "is_return"
},
"validation": {
"docstatus": ["=", 1],