chore: Update allow on submit for Sales Invoice fields

This commit is contained in:
Deepesh Garg 2022-10-17 16:48:13 +05:30
parent 30da6ab2c1
commit e626107d3d
5 changed files with 32 additions and 15 deletions

View File

@ -76,13 +76,11 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends e
callback: (r) => { callback: (r) => {
if (!r.exc) { if (!r.exc) {
frappe.msgprint(__('Accounting Entries are reposted')); frappe.msgprint(__('Accounting Entries are reposted'));
this.frm.trigger('refresh'); me.frm.refresh();
} }
} }
}); });
}); }).removeClass('btn-default').addClass('btn-warning');
$(`["${encodeURIComponent("Repost Accounting Entries")}"]`).css('color', 'red');
} }
if (this.frm.doc.is_return) { if (this.frm.doc.is_return) {

View File

@ -522,9 +522,10 @@ class SalesInvoice(SellingController):
def on_update_after_submit(self): def on_update_after_submit(self):
needs_repost = 0 needs_repost = 0
# Check if any field affecting accounting entry is altered # Check if any field affecting accounting entry is altered
doc_before_update = self.get_doc_before_save() doc_before_update = self.get_doc_before_save()
accounting_dimensions = get_accounting_dimensions() accounting_dimensions = get_accounting_dimensions() + ["cost_center", "project"]
# Check if opening entry check updated # Check if opening entry check updated
if doc_before_update.get("is_opening") != self.is_opening: if doc_before_update.get("is_opening") != self.is_opening:
@ -552,12 +553,7 @@ class SalesInvoice(SellingController):
# Check for parent level # Check for parent level
for index, item in enumerate(self.get("items")): for index, item in enumerate(self.get("items")):
for field in ( for field in ("income_account", "expense_account", "discount_account"):
"income_account",
"expense_account",
"discount_account",
"deferred_revenue_account",
):
if doc_before_update.get("items")[index].get(field) != item.get(field): if doc_before_update.get("items")[index].get(field) != item.get(field):
needs_repost = 1 needs_repost = 1
break break
@ -567,6 +563,16 @@ class SalesInvoice(SellingController):
needs_repost = 1 needs_repost = 1
break break
for index, tax in enumerate(self.get("taxes")):
if doc_before_update.get("taxes")[index].get("account_head") != tax.get("account_head"):
needs_repost = 1
break
for dimension in accounting_dimensions:
if doc_before_update.get("taxes")[index].get(dimension) != tax.get(dimension):
needs_repost = 1
break
self.validate_accounts() self.validate_accounts()
self.db_set("repost_required", needs_repost) self.db_set("repost_required", needs_repost)

View File

@ -436,6 +436,7 @@
"label": "Accounting Details" "label": "Accounting Details"
}, },
{ {
"allow_on_submit": 1,
"fieldname": "income_account", "fieldname": "income_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Income Account", "label": "Income Account",
@ -448,6 +449,7 @@
"width": "120px" "width": "120px"
}, },
{ {
"allow_on_submit": 1,
"fieldname": "expense_account", "fieldname": "expense_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Expense Account", "label": "Expense Account",
@ -467,6 +469,7 @@
"print_hide": 1 "print_hide": 1
}, },
{ {
"allow_on_submit": 1,
"default": ":Company", "default": ":Company",
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
@ -798,6 +801,7 @@
"options": "Finance Book" "options": "Finance Book"
}, },
{ {
"allow_on_submit": 1,
"fieldname": "project", "fieldname": "project",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Project", "label": "Project",
@ -820,7 +824,6 @@
"label": "Incoming Rate (Costing)", "label": "Incoming Rate (Costing)",
"no_copy": 1, "no_copy": 1,
"options": "Company:company:default_currency", "options": "Company:company:default_currency",
"precision": "6",
"print_hide": 1 "print_hide": 1
}, },
{ {
@ -833,6 +836,7 @@
"read_only": 1 "read_only": 1
}, },
{ {
"allow_on_submit": 1,
"fieldname": "discount_account", "fieldname": "discount_account",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Discount Account", "label": "Discount Account",
@ -876,7 +880,7 @@
"idx": 1, "idx": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2022-10-10 20:57:38.340026", "modified": "2022-10-17 12:51:44.825398",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice Item", "name": "Sales Invoice Item",

View File

@ -51,6 +51,7 @@
"oldfieldtype": "Data" "oldfieldtype": "Data"
}, },
{ {
"allow_on_submit": 1,
"columns": 2, "columns": 2,
"fieldname": "account_head", "fieldname": "account_head",
"fieldtype": "Link", "fieldtype": "Link",
@ -63,6 +64,7 @@
"search_index": 1 "search_index": 1
}, },
{ {
"allow_on_submit": 1,
"default": ":Company", "default": ":Company",
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
@ -216,12 +218,13 @@
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"istable": 1, "istable": 1,
"links": [], "links": [],
"modified": "2021-08-05 20:04:01.726867", "modified": "2022-10-17 13:08:17.776528",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Taxes and Charges", "name": "Sales Taxes and Charges",
"owner": "Administrator", "owner": "Administrator",
"permissions": [], "permissions": [],
"sort_field": "modified", "sort_field": "modified",
"sort_order": "ASC" "sort_order": "ASC",
"states": []
} }

View File

@ -143,6 +143,12 @@ var get_payment_mode_account = function(frm, mode_of_payment, callback) {
cur_frm.cscript.account_head = function(doc, cdt, cdn) { cur_frm.cscript.account_head = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if (doc.docstatus == 1) {
// Should not trigger any changes on change post submit
return;
}
if(!d.charge_type && d.account_head){ if(!d.charge_type && d.account_head){
frappe.msgprint(__("Please select Charge Type first")); frappe.msgprint(__("Please select Charge Type first"));
frappe.model.set_value(cdt, cdn, "account_head", ""); frappe.model.set_value(cdt, cdn, "account_head", "");