From 707b630851659eea04c4c71740689c11ec94247f Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 19 Nov 2020 18:42:39 +0530 Subject: [PATCH 1/6] fix: add remarks to sales invoice --- .../doctype/sales_invoice/sales_invoice.py | 9 +++-- erpnext/patches.txt | 3 +- .../v12_0/update_sales_invoice_remarks.py | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v12_0/update_sales_invoice_remarks.py diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 2f8b782356d..94bc400fe5b 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 +from frappe.utils import cint, flt, add_months, today, date_diff, getdate, add_days, cstr, nowdate, formatdate from frappe import _, msgprint, throw from erpnext.accounts.party import get_party_account, get_due_date from erpnext.controllers.stock_controller import update_gl_entries_after @@ -530,7 +530,12 @@ class SalesInvoice(SellingController): 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 b5f31bafa7e..2615830eb0a 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -677,4 +677,5 @@ erpnext.patches.v12_0.set_multi_uom_in_rfq erpnext.patches.v12_0.update_state_code_for_daman_and_diu erpnext.patches.v12_0.rename_lost_reason_detail erpnext.patches.v12_0.update_leave_application_status -erpnext.patches.v12_0.update_payment_entry_status \ No newline at end of file +erpnext.patches.v12_0.update_payment_entry_status +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 00000000000..5443d133a2e --- /dev/null +++ b/erpnext/patches/v12_0/update_sales_invoice_remarks.py @@ -0,0 +1,35 @@ +from __future__ import unicode_literals +from mmap import PAGESIZE +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 From 51a153d8c27ef27c8fc965bff7ac413e238c134f Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 19 Nov 2020 19:03:22 +0530 Subject: [PATCH 2/6] fix: removed unused code --- erpnext/patches/v12_0/update_sales_invoice_remarks.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/patches/v12_0/update_sales_invoice_remarks.py b/erpnext/patches/v12_0/update_sales_invoice_remarks.py index 5443d133a2e..ae6443d3171 100644 --- a/erpnext/patches/v12_0/update_sales_invoice_remarks.py +++ b/erpnext/patches/v12_0/update_sales_invoice_remarks.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -from mmap import PAGESIZE import frappe from frappe import _ @@ -30,6 +29,4 @@ def execute(): ) for entry in gl_entry_list: - frappe.db.set_value('GL Entry', entry.name, 'remarks', remarks) - - \ No newline at end of file + frappe.db.set_value('GL Entry', entry.name, 'remarks', remarks) \ No newline at end of file From c630be6781f571ebda3f29cdd58759f75f73bcf4 Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 19 Nov 2020 19:13:06 +0530 Subject: [PATCH 3/6] fix: remove unused imports --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 94bc400fe5b..1b77f1b733b 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, formatdate +from frappe.utils import cint, flt, getdate, add_days, cstr, nowdate, formatdate from frappe import _, msgprint, throw from erpnext.accounts.party import get_party_account, get_due_date from erpnext.controllers.stock_controller import update_gl_entries_after From ef06f3288f5475f54daecb281b60065165371ed3 Mon Sep 17 00:00:00 2001 From: vorasmit Date: Fri, 1 Jan 2021 10:48:44 +0530 Subject: [PATCH 4/6] Delete update_sales_invoice_remarks.py --- .../v12_0/update_sales_invoice_remarks.py | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 erpnext/patches/v12_0/update_sales_invoice_remarks.py diff --git a/erpnext/patches/v12_0/update_sales_invoice_remarks.py b/erpnext/patches/v12_0/update_sales_invoice_remarks.py deleted file mode 100644 index ae6443d3171..00000000000 --- a/erpnext/patches/v12_0/update_sales_invoice_remarks.py +++ /dev/null @@ -1,32 +0,0 @@ -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 From 82b4749166eaf2970dbf35b98e92237e09df67ca Mon Sep 17 00:00:00 2001 From: vorasmit Date: Fri, 1 Jan 2021 10:49:48 +0530 Subject: [PATCH 5/6] Update patches.txt --- erpnext/patches.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 2615830eb0a..b9d48069238 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -678,4 +678,3 @@ erpnext.patches.v12_0.update_state_code_for_daman_and_diu erpnext.patches.v12_0.rename_lost_reason_detail erpnext.patches.v12_0.update_leave_application_status erpnext.patches.v12_0.update_payment_entry_status -erpnext.patches.v12_0.update_sales_invoice_remarks \ No newline at end of file