fixed renaming patch

This commit is contained in:
Nabin Hait 2015-02-18 15:10:29 +05:30
parent 06fd10620e
commit 8626d3881d
3 changed files with 17 additions and 11 deletions

View File

@ -340,7 +340,7 @@
"read_only": 1
},
{
"fieldname": "base_taxes_and_charges",
"fieldname": "base_total_taxes_and_charges",
"fieldtype": "Currency",
"label": "Total Taxes and Charges (Company Currency)",
"no_copy": 1,
@ -783,7 +783,7 @@
"icon": "icon-file-text",
"idx": 1,
"is_submittable": 1,
"modified": "2015-02-11 16:13:52.294735",
"modified": "2015-02-18 15:05:33.635613",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
@ -854,7 +854,7 @@
}
],
"read_only_onload": 1,
"search_fields": "status, transaction_date, supplier,base_grand_total",
"search_fields": "status, transaction_date, supplier,grand_total",
"sort_field": "modified",
"sort_order": "DESC",
"title_field": "supplier_name"

View File

@ -295,6 +295,7 @@ class calculate_taxes_and_totals(object):
self.doc.base_grand_total = flt(self.doc.get("taxes")[-1].total
if self.doc.get("taxes") else self.doc.base_net_total)
print self.doc
self.doc.base_total_taxes_and_charges = flt(self.doc.base_grand_total - self.doc.base_net_total,
self.doc.precision("base_total_taxes_and_charges"))

View File

@ -29,7 +29,6 @@ buying_renamed_fields = (
("grand_total", "base_grand_total"),
("grand_total_import", "grand_total"),
("rounded_total", "base_rounded_total"),
("rounded_total_import", "rounded_total"),
("in_words", "base_in_words"),
("in_words_import", "in_words"),
("other_charges_added", "base_taxes_and_charges_added"),
@ -40,12 +39,18 @@ buying_renamed_fields = (
)
def execute():
for dt in selling_doctypes:
frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
for doctypes, fields in [[selling_doctypes, selling_renamed_fields], [buying_doctypes, buying_renamed_fields]]:
for dt in doctypes:
base_net_total = frappe.db.sql("select sum(ifnull({0}, 0)) from `tab{1}`".format(fields[0][1], dt))[0][0]
if not base_net_total:
meta = frappe.get_meta(dt)
frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
for f in selling_renamed_fields:
rename_field(dt, f[0], f[1])
for f in fields:
if meta.get_field(f[0]):
rename_field(dt, f[0], f[1])
# Added new field "total_taxes_and_charges" in buying cycle, updating value
frappe.db.sql("""update `tab{0}`
set total_taxes_and_charges = round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))
# Added new field "total_taxes_and_charges" in buying cycle, updating value
if dt in ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"):
frappe.db.sql("""update `tab{0}` set total_taxes_and_charges =
round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))