Item website specification from item group

This commit is contained in:
Nabin Hait 2014-06-27 15:19:26 +05:30
parent 4e4a83bcef
commit 7c9652997b
3 changed files with 13 additions and 8 deletions

View File

@ -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':

View File

@ -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"
});
}

View File

@ -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")