From 7c9652997bd4e6215e7786e0f5c97a8234ba5c89 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 27 Jun 2014 15:19:26 +0530 Subject: [PATCH] Item website specification from item group --- .../accounts/doctype/sales_invoice/sales_invoice.py | 2 +- erpnext/stock/doctype/item/item.js | 10 +++------- erpnext/stock/doctype/item/item.py | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 262ac22386..834865bcd6 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -262,7 +262,7 @@ class SalesInvoice(SellingController): """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 173a1cfc41..93c1191da5 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -169,13 +169,9 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query = } 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 f43b531392..1f163890ba 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -256,6 +256,15 @@ class Item(WebsiteGenerator): 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")