Added ability to create a Return Sales Invoice/ Credit Note against a delivery note of type return (#15266)
* Remove make subscription button on delivery note if it is of type returns * Added 'issue_credit_note' checkbox on delivery note to pass a Sales Inv of type return if checked while creating a return delivery note * Added logic to auto-create Return Sales Invoice/ Credit Note if issue_credit_note checkbox is checked while return delivey note is submited * Update delivery_note.py
This commit is contained in:
parent
4b290e5561
commit
6f77abe0dd
@ -167,7 +167,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
}
|
||||
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
|
||||
|
||||
if(doc.docstatus==1 && !doc.auto_repeat) {
|
||||
if(doc.docstatus==1 && !doc.is_return && !doc.auto_repeat) {
|
||||
cur_frm.add_custom_button(__('Subscription'), function() {
|
||||
erpnext.utils.make_subscription(doc.doctype, doc.name)
|
||||
}, __("Make"))
|
||||
|
@ -456,6 +456,39 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "is_return",
|
||||
"fieldname": "issue_credit_note",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Issue Credit Note",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
@ -4168,7 +4201,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2018-08-29 04:03:32.749794",
|
||||
"modified": "2018-08-30 03:50:25.791869",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Delivery Note",
|
||||
|
@ -212,7 +212,8 @@ class DeliveryNote(SellingController):
|
||||
|
||||
if not self.is_return:
|
||||
self.check_credit_limit()
|
||||
|
||||
elif self.issue_credit_note:
|
||||
self.make_return_invoice()
|
||||
# Updating stock ledger should always be called after updating prevdoc status,
|
||||
# because updating reserved qty in bin depends upon updated delivered qty in SO
|
||||
self.update_stock_ledger()
|
||||
@ -314,6 +315,16 @@ class DeliveryNote(SellingController):
|
||||
|
||||
self.load_from_db()
|
||||
|
||||
def make_return_invoice(self):
|
||||
try:
|
||||
return_invoice = make_sales_invoice(self.name)
|
||||
return_invoice.is_return = True
|
||||
return_invoice.save()
|
||||
return_invoice.submit()
|
||||
frappe.msgprint(_("Credit Note {0} has been created automatically").format(return_invoice.name))
|
||||
except:
|
||||
frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again"))
|
||||
|
||||
def update_billed_amount_based_on_so(so_detail, update_modified=True):
|
||||
# Billed against Sales Order directly
|
||||
billed_against_so = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
|
||||
|
Loading…
Reference in New Issue
Block a user