[print] Disable rounded total
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index c29f2d8..44d5b3a 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -73,3 +73,4 @@
execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool Detail") # 29-07-2014
execute:frappe.delete_doc("Page", "trial-balance") #2014-07-22
erpnext.patches.v4_2.delete_old_print_formats #2014-07-29
+erpnext.patches.v4_2.toggle_rounded_total
diff --git a/erpnext/patches/v4_2/toggle_rounded_total.py b/erpnext/patches/v4_2/toggle_rounded_total.py
new file mode 100644
index 0000000..aa63fdc
--- /dev/null
+++ b/erpnext/patches/v4_2/toggle_rounded_total.py
@@ -0,0 +1,9 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+ global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
+ global_defaults.toggle_rounded_total()
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index fff7ef9..20f1028 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -16,7 +16,6 @@
erpnext.selling.SellingController = erpnext.TransactionController.extend({
onload: function() {
this._super();
- this.toggle_rounded_total();
this.setup_queries();
this.toggle_editable_price_list_rate();
},
@@ -229,16 +228,6 @@
}
},
- toggle_rounded_total: function() {
- var me = this;
- if(cint(frappe.defaults.get_global_default("disable_rounded_total"))) {
- $.each(["rounded_total", "rounded_total_export"], function(i, fieldname) {
- me.frm.set_df_property(fieldname, "print_hide", 1);
- me.frm.toggle_display(fieldname, false);
- });
- }
- },
-
toggle_editable_price_list_rate: function() {
var df = frappe.meta.get_docfield(this.tname, "price_list_rate", this.frm.doc.name);
var editable_price_list_rate = cint(frappe.defaults.get_default("editable_price_list_rate"));
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py
index 737c17e..4764484 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.py
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.py
@@ -5,6 +5,8 @@
"""Global Defaults"""
import frappe
import frappe.defaults
+from frappe.utils import cint
+from frappe.core.doctype.property_setter.property_setter import make_property_setter
keydict = {
# "key in defaults": "key in Global Defaults"
@@ -42,8 +44,19 @@
if self.default_currency:
frappe.db.set_value("Currency", self.default_currency, "enabled", 1)
+ self.toggle_rounded_total()
+
# clear cache
frappe.clear_cache()
def get_defaults(self):
return frappe.defaults.get_defaults()
+
+ def toggle_rounded_total(self):
+ self.disable_rounded_total = cint(self.disable_rounded_total)
+
+ # Make property setters to hide rounded total fields
+ for doctype in ("Quotation", "Sales Order", "Sales Invoice", "Delivery Note"):
+ for fieldname in ("rounded_total", "rounded_total_export"):
+ make_property_setter(doctype, fieldname, "hidden", self.disable_rounded_total, "Check")
+ make_property_setter(doctype, fieldname, "print_hide", self.disable_rounded_total, "Check")