fix: add remarks to sales invoice
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index af6c696..0530aa2 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe, erpnext
import frappe.defaults
-from frappe.utils import cint, flt, add_months, today, date_diff, getdate, add_days, cstr, nowdate, get_link_to_form
+from frappe.utils import cint, flt, getdate, add_days, cstr, nowdate, get_link_to_form, formatdate
from frappe import _, msgprint, throw
from erpnext.accounts.party import get_party_account, get_due_date
from frappe.model.mapper import get_mapped_doc
@@ -535,7 +535,12 @@
self.against_income_account = ','.join(against_acc)
def add_remarks(self):
- if not self.remarks: self.remarks = 'No Remarks'
+ if not self.remarks:
+ if self.po_no and self.po_date:
+ self.remarks = _("Against Customer Order {0} dated {1}").format(self.po_no,
+ formatdate(self.po_date))
+ else:
+ self.remarks = _("No Remarks")
def validate_auto_set_posting_time(self):
# Don't auto set the posting date and time if invoice is amended
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 25be884..4a38cb3 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -735,3 +735,4 @@
erpnext.patches.v13_0.update_reason_for_resignation_in_employee
erpnext.patches.v13_0.update_custom_fields_for_shopify
execute:frappe.delete_doc("Report", "Quoted Item Comparison")
+erpnext.patches.v12_0.update_sales_invoice_remarks
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/update_sales_invoice_remarks.py b/erpnext/patches/v12_0/update_sales_invoice_remarks.py
new file mode 100644
index 0000000..7e8feaa
--- /dev/null
+++ b/erpnext/patches/v12_0/update_sales_invoice_remarks.py
@@ -0,0 +1,32 @@
+from __future__ import unicode_literals
+import frappe
+
+from frappe import _
+from frappe.utils import formatdate
+
+def execute():
+ si_list = frappe.db.get_all('Sales Invoice', filters = {
+ 'docstatus': 1,
+ 'remarks': 'No Remarks',
+ 'po_no' : ['!=', ''],
+ 'po_date' : ['!=', '']
+ },
+ fields = ['name', 'po_no', 'po_date']
+ )
+
+ for doc in si_list:
+ remarks = _("Against Customer Order {0} dated {1}").format(doc.po_no,
+ formatdate(doc.po_date))
+
+ frappe.db.set_value('Sales Invoice', doc.name, 'remarks', remarks)
+
+ gl_entry_list = frappe.db.get_all('GL Entry', filters = {
+ 'voucher_type': 'Sales Invoice',
+ 'remarks': 'No Remarks',
+ 'voucher_no' : doc.name
+ },
+ fields = ['name']
+ )
+
+ for entry in gl_entry_list:
+ frappe.db.set_value('GL Entry', entry.name, 'remarks', remarks)
\ No newline at end of file