Item website specification from item group
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 262ac22..834865b 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -262,7 +262,7 @@
"""Validate Fixed Asset and whether Income Account Entered Exists"""
for d in self.get('entries'):
item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem`
- where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""", d.item_code)
+ where name = %s""", d.item_code)
acc = frappe.db.sql("""select account_type from `tabAccount`
where name = %s and docstatus != 2""", d.income_account)
if item and item[0][1] == 'Yes' and acc and acc[0][0] != 'Fixed Asset':
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 173a1cf..93c1191 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -169,13 +169,9 @@
}
cur_frm.cscript.copy_from_item_group = function(doc) {
- frappe.model.with_doc("Item Group", doc.item_group, function(name, r) {
- $.each((r.docs[0].item_website_specifications || []), function(i, d) {
- var n = frappe.model.add_child(doc, "Item Website Specification", "item_website_specifications");
- n.label = d.label;
- n.description = d.description;
- });
- cur_frm.refresh();
+ return cur_frm.call({
+ doc: doc,
+ method: "copy_specification_from_item_group"
});
}
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f43b531..1f16389 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -256,6 +256,15 @@
frappe.db.get_value("Stock Settings", None, "allow_negative_stock"))
frappe.db.auto_commit_on_many_writes = 0
+ def copy_specification_from_item_group(self):
+ self.set("item_website_specifications", [])
+ if self.item_group:
+ for label, desc in frappe.db.get_values("Item Website Specification",
+ {"parent": self.item_group}, ["label", "description"]):
+ row = self.append("item_website_specifications")
+ row.label = label
+ row.description = desc
+
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
if not end_of_life:
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")