From 7f70367ddebfb7c992c40f0adb1dc046ef7fa98f Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 12 Feb 2015 12:54:52 +0530 Subject: [PATCH] image view fixed for stock entry and bom --- erpnext/manufacturing/doctype/bom/bom.js | 7 +++- erpnext/manufacturing/doctype/bom/bom.json | 27 ++++++++++++++ erpnext/manufacturing/doctype/bom/bom.py | 17 +++++---- .../bom_explosion_item.json | 33 +++++++++++++++-- .../doctype/bom_item/bom_item.json | 37 ++++++++++++++++--- .../stock/doctype/stock_entry/stock_entry.js | 31 +++++++++++----- .../stock/doctype/stock_entry/stock_entry.py | 4 +- 7 files changed, 128 insertions(+), 28 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index a230cf4ab9..22bddaa69a 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -23,6 +23,7 @@ cur_frm.cscript.update_cost = function() { } cur_frm.add_fetch("item", "description", "description"); +cur_frm.add_fetch("item", "image", "image"); cur_frm.add_fetch("item", "item_name", "item_name"); cur_frm.add_fetch("item", "stock_uom", "uom"); @@ -201,4 +202,8 @@ frappe.ui.form.on("BOM Operation", "operations_remove", function(frm) { frappe.ui.form.on("BOM Item", "items_remove", function(frm) { erpnext.bom.calculate_rm_cost(frm.doc); erpnext.bom.calculate_total(frm.doc); -}); \ No newline at end of file +}); + +cur_frm.cscript.image = function() { + refresh_field("image_view"); +} \ No newline at end of file diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json index 05350d5877..8866100cc5 100644 --- a/erpnext/manufacturing/doctype/bom/bom.json +++ b/erpnext/manufacturing/doctype/bom/bom.json @@ -213,6 +213,12 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "section_break_25", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "description", "fieldtype": "Small Text", @@ -221,6 +227,27 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "column_break_27", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "image", + "fieldtype": "Attach", + "label": "Image", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "Image_view", + "fieldtype": "Image", + "label": "Image View", + "options": "image", + "permlevel": 0, + "precision": "" + }, { "depends_on": "eval:!doc.__islocal", "fieldname": "section_break0", diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 702fdef4ec..6c50c86d0e 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -55,7 +55,7 @@ class BOM(Document): def get_item_det(self, item_code): item = frappe.db.sql("""select name, item_name, is_asset_item, is_purchase_item, - docstatus, description, is_sub_contracted_item, stock_uom, default_bom, + docstatus, description, image, is_sub_contracted_item, stock_uom, default_bom, last_purchase_rate from `tabItem` where name=%s""", item_code, as_dict = 1) @@ -96,6 +96,7 @@ class BOM(Document): ret_item = { 'item_name' : item and args['item_name'] or '', 'description' : item and args['description'] or '', + 'image' : item and args['image'] or '', 'stock_uom' : item and args['stock_uom'] or '', 'bom_no' : args['bom_no'], 'rate' : rate @@ -298,12 +299,13 @@ class BOM(Document): self.get_child_exploded_items(d.bom_no, d.qty) else: self.add_to_cur_exploded_items(frappe._dict({ - 'item_code' : d.item_code, - 'item_name' : d.item_name, - 'description' : d.description, - 'stock_uom' : d.stock_uom, - 'qty' : flt(d.qty), - 'rate' : flt(d.rate), + 'item_code' : d.item_code, + 'item_name' : d.item_name, + 'description' : d.description, + 'image' : d.image, + 'stock_uom' : d.stock_uom, + 'qty' : flt(d.qty), + 'rate' : flt(d.rate), })) def add_to_cur_exploded_items(self, args): @@ -367,6 +369,7 @@ def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1): item.item_name, sum(ifnull(bom_item.qty, 0)/ifnull(bom.quantity, 1)) * %(qty)s as qty, item.description, + item.image, item.stock_uom, item.default_warehouse, item.expense_account as expense_account, diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json index 71b6da5f8d..aa5294ce5a 100644 --- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json +++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json @@ -16,6 +16,12 @@ "permlevel": 0, "read_only": 1 }, + { + "fieldname": "cb", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "item_name", "fieldtype": "Data", @@ -26,8 +32,8 @@ "read_only": 1 }, { - "fieldname": "column_break_2", - "fieldtype": "Column Break", + "fieldname": "section_break_3", + "fieldtype": "Section Break", "permlevel": 0, "precision": "" }, @@ -43,6 +49,27 @@ "read_only": 1, "width": "300px" }, + { + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "image", + "fieldtype": "Attach", + "label": "Image", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "image_view", + "fieldtype": "Image", + "label": "Image View", + "options": "image", + "permlevel": 0, + "precision": "" + }, { "fieldname": "section_break_4", "fieldtype": "Section Break", @@ -111,7 +138,7 @@ ], "idx": 1, "istable": 1, - "modified": "2015-01-20 13:28:52.258152", + "modified": "2015-02-12 12:23:57.127210", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Explosion Item", diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json index 6786ead00b..2459b8e1bd 100644 --- a/erpnext/manufacturing/doctype/bom_item/bom_item.json +++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json @@ -24,6 +24,12 @@ "permlevel": 0, "precision": "" }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "permlevel": 0, + "precision": "" + }, { "fieldname": "bom_no", "fieldtype": "Link", @@ -40,9 +46,10 @@ "width": "150px" }, { - "fieldname": "col_break1", - "fieldtype": "Column Break", - "permlevel": 0 + "fieldname": "section_break_5", + "fieldtype": "Section Break", + "permlevel": 0, + "precision": "" }, { "fieldname": "description", @@ -55,6 +62,26 @@ "reqd": 0, "width": "250px" }, + { + "fieldname": "col_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "fieldname": "image", + "fieldtype": "Attach", + "label": "Image", + "permlevel": 0, + "precision": "" + }, + { + "fieldname": "image_view", + "fieldtype": "Image", + "label": "Image View", + "options": "image", + "permlevel": 0, + "precision": "" + }, { "fieldname": "quantity_and_rate", "fieldtype": "Section Break", @@ -133,8 +160,8 @@ } ], "idx": 1, - "istable": 1, - "modified": "2015-01-20 13:28:35.152945", + "istable": 1, + "modified": "2015-02-12 10:41:31.336921", "modified_by": "Administrator", "module": "Manufacturing", "name": "BOM Item", diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index a77aa748ea..527cbf3032 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -384,9 +384,9 @@ cur_frm.fields_dict['items'].grid.get_field('batch_no').get_query = function(doc return{ query: "erpnext.stock.doctype.stock_entry.stock_entry.get_batch_no", filters:{ - 'item_code': d.item_code, - 's_warehouse': d.s_warehouse, - 'posting_date': doc.posting_date + 'item_code' : d.item_code, + 's_warehouse' : d.s_warehouse, + 'posting_date' : doc.posting_date } } } else { @@ -398,17 +398,28 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(d.item_code) { args = { - 'item_code' : d.item_code, - 'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse), + 'item_code' : d.item_code, + 'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse), 'transfer_qty' : d.transfer_qty, - 'serial_no' : d.serial_no, - 'bom_no' : d.bom_no, + 'serial_no ' : d.serial_no, + 'bom_no' : d.bom_no, 'expense_account' : d.expense_account, 'cost_center' : d.cost_center, - 'company' : cur_frm.doc.company + 'company' : cur_frm.doc.company }; - return get_server_fields('get_item_details', JSON.stringify(args), - 'items', doc, cdt, cdn, 1); + return frappe.call({ + doc: cur_frm.doc, + method: "get_item_details", + args: args, + callback: function(r) { + if(r.message) { + $.each(r.message, function(k, v) { + frappe.model.set_value(cdt, cdn, k, v); + }); + refresh_field('image_view', d.name, 'items'); + } + } + }); } } diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 8b47df7fe3..62c83edf90 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -431,7 +431,7 @@ class StockEntry(StockController): "planned_qty": (self.docstatus==1 and -1 or 1 ) * flt(self.fg_completed_qty) }) - def get_item_details(self, args): + def get_item_details(self, args=None): item = frappe.db.sql("""select stock_uom, description, image, item_name, expense_account, buying_cost_center, item_group from `tabItem` where name = %s and (ifnull(end_of_life,'0000-00-00')='0000-00-00' or end_of_life > now())""", @@ -452,7 +452,7 @@ class StockEntry(StockController): 'qty' : 0, 'transfer_qty' : 0, 'conversion_factor' : 1, - 'batch_no' : '', + 'batch_no' : '', 'actual_qty' : 0, 'incoming_rate' : 0 }