Merge pull request #4195 from anandpdoshi/journal-entry-posting-date
[enhancement] Quick Entry in Journal Entry, remember Posting Date
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 9c4ccdc..94c0c62 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -144,20 +144,21 @@
filters={"variant_of": self.name, "show_in_website": 1}, order_by="name asc")
variant = frappe.form_dict.variant
- if not variant:
+ if not variant and context.variants:
# the case when the item is opened for the first time from its list
variant = context.variants[0]
- context.variant = frappe.get_doc("Item", variant)
+ if variant:
+ context.variant = frappe.get_doc("Item", variant)
- for fieldname in ("website_image", "web_long_description", "description",
- "website_specifications"):
- if context.variant.get(fieldname):
- value = context.variant.get(fieldname)
- if isinstance(value, list):
- value = [d.as_dict() for d in value]
+ for fieldname in ("website_image", "web_long_description", "description",
+ "website_specifications"):
+ if context.variant.get(fieldname):
+ value = context.variant.get(fieldname)
+ if isinstance(value, list):
+ value = [d.as_dict() for d in value]
- context[fieldname] = value
+ context[fieldname] = value
if self.slideshow:
if context.variant and context.variant.slideshow:
@@ -412,10 +413,11 @@
if not template_item.show_in_website:
template_item.show_in_website = 1
template_item.flags.ignore_permissions = True
+ template_item.flags.dont_update_variants = True
template_item.save()
def update_variants(self):
- if self.has_variants:
+ if self.has_variants and not self.flags.dont_update_variants:
updated = []
variants = frappe.db.get_all("Item", fields=["item_code"], filters={"variant_of": self.name })
for d in variants:
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js
index 2632ddd..77d2ba3 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.js
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.js
@@ -21,7 +21,7 @@
select_doctype: frm.doc.select_doctype
},
callback: function(r) {
- frm.get_field("rename_log").$wrapper.html(r.message);
+ frm.get_field("rename_log").$wrapper.html(r.message.join("<br>"));
}
});
});
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py
index 18cfebe..5e33f5f 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.py
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py
@@ -5,9 +5,9 @@
from __future__ import unicode_literals
import frappe
-from frappe import _
from frappe.model.document import Document
+from frappe.model.rename_doc import bulk_rename
class RenameTool(Document):
pass
@@ -20,37 +20,13 @@
@frappe.whitelist()
def upload(select_doctype=None, rows=None):
from frappe.utils.csvutils import read_csv_content_from_attached_file
- from frappe.model.rename_doc import rename_doc
-
if not select_doctype:
select_doctype = frappe.form_dict.select_doctype
if not frappe.has_permission(select_doctype, "write"):
raise frappe.PermissionError
- if not rows:
- rows = read_csv_content_from_attached_file(frappe.get_doc("Rename Tool", "Rename Tool"))
- if not rows:
- frappe.throw(_("Please select a valid csv file with data"))
+ rows = read_csv_content_from_attached_file(frappe.get_doc("Rename Tool", "Rename Tool"))
- max_rows = 500
- if len(rows) > max_rows:
- frappe.throw(_("Maximum {0} rows allowed").format(max_rows))
+ return bulk_rename(select_doctype, rows=rows)
- rename_log = []
- for row in rows:
- # if row has some content
- if len(row) > 1 and row[0] and row[1]:
- try:
- if rename_doc(select_doctype, row[0], row[1]):
- rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
- frappe.db.commit()
- else:
- rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
- except Exception, e:
- rename_log.append("<span style='color: RED'>" + \
- _("Failed: ") + row[0] + " -> " + row[1] + "</span>")
- rename_log.append("<span style='margin-left: 20px;'>" + repr(e) + "</span>")
- frappe.db.rollback()
-
- return rename_log