image view fixed for stock entry and bom

This commit is contained in:
Neil Trini Lasrado 2015-02-12 12:54:52 +05:30
parent 3361df709c
commit 7f70367dde
7 changed files with 128 additions and 28 deletions

View File

@ -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);
});
});
cur_frm.cscript.image = function() {
refresh_field("image_view");
}

View File

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

View File

@ -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,

View File

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

View File

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

View File

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

View File

@ -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
}