fix: add remarks to sales invoice

This commit is contained in:
Smit Vora 2020-11-19 19:18:48 +05:30
parent 67ba0462e9
commit 8aeb340dc8
3 changed files with 40 additions and 2 deletions

View File

@ -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 @@ 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

View File

@ -735,3 +735,4 @@ erpnext.patches.v13_0.create_healthcare_custom_fields_in_stock_entry_detail
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

View File

@ -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)