html item desc removed from item master, item image added in oppurtunity
This commit is contained in:
parent
9f138b21fa
commit
66df3566a9
@ -94,8 +94,21 @@ cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
return get_server_fields('get_item_details', d.item_code,
|
||||
'items', doc, cdt, cdn, 1);
|
||||
return frappe.call({
|
||||
method: "erpnext.selling.doctype.opportunity.opportunity.get_item_details",
|
||||
args: {"item_code":d.item_code},
|
||||
callback: function(r, rt) {
|
||||
if(r.message) {
|
||||
frappe.model.set_value(d.doctype, d.name, "description", r.message.description);
|
||||
frappe.model.set_value(d.doctype, d.name, "item_name", r.message.item_name);
|
||||
frappe.model.set_value(d.doctype, d.name, "brand", r.message.brand);
|
||||
frappe.model.set_value(d.doctype, d.name, "uom", r.message.uom);
|
||||
frappe.model.set_value(d.doctype, d.name, "item_group", r.message.item_group);
|
||||
frappe.model.set_value(d.doctype, d.name, "image", r.message.image);
|
||||
refresh_field('image_view', d.name, 'items');
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,18 +59,6 @@ class Opportunity(TransactionBase):
|
||||
|
||||
def validate_cust_name(self):
|
||||
self.customer_name = self.customer or self.lead
|
||||
|
||||
def get_item_details(self, item_code):
|
||||
item = frappe.db.sql("""select item_name, stock_uom, description_html, description, item_group, brand
|
||||
from `tabItem` where name = %s""", item_code, as_dict=1)
|
||||
ret = {
|
||||
'item_name': item and item[0]['item_name'] or '',
|
||||
'uom': item and item[0]['stock_uom'] or '',
|
||||
'description': item and item[0]['description_html'] or item[0]['description'] or '',
|
||||
'item_group': item and item[0]['item_group'] or '',
|
||||
'brand': item and item[0]['brand'] or ''
|
||||
}
|
||||
return ret
|
||||
|
||||
def get_cust_address(self,name):
|
||||
details = frappe.db.sql("""select customer_name, address, territory, customer_group
|
||||
@ -140,7 +128,20 @@ class Opportunity(TransactionBase):
|
||||
msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1)
|
||||
else:
|
||||
self.lead = None
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_item_details(item_code):
|
||||
item = frappe.db.sql("""select item_name, stock_uom, image, description, item_group, brand
|
||||
from `tabItem` where name = %s""", item_code, as_dict=1)
|
||||
return {
|
||||
'item_name': item and item[0]['item_name'] or '',
|
||||
'uom': item and item[0]['stock_uom'] or '',
|
||||
'description': item and item[0]['description'] or '',
|
||||
'image': item and item[0]['image'] or '',
|
||||
'item_group': item and item[0]['item_group'] or '',
|
||||
'brand': item and item[0]['brand'] or ''
|
||||
}
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_quotation(source_name, target_doc=None):
|
||||
def set_missing_values(source, target):
|
||||
|
@ -14,6 +14,11 @@
|
||||
"permlevel": 0,
|
||||
"reqd": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
@ -52,9 +57,10 @@
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "col_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0
|
||||
"fieldname": "section_break_6",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
@ -68,6 +74,29 @@
|
||||
"reqd": 1,
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_8",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 0,
|
||||
"label": "Image",
|
||||
"options": "",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image_view",
|
||||
"fieldtype": "Image",
|
||||
"label": "Image View",
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "quantity_and_rate",
|
||||
"fieldtype": "Section Break",
|
||||
@ -115,7 +144,7 @@
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2015-01-01 14:29:58.657537",
|
||||
"modified": "2015-02-10 13:03:39.188558",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Opportunity Item",
|
||||
|
@ -150,22 +150,6 @@ cur_frm.fields_dict['item_group'].get_query = function(doc,cdt,cdn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.add_image = function(doc, dt, dn) {
|
||||
if(!doc.image) {
|
||||
msgprint(__('Please select an "Image" first'));
|
||||
return;
|
||||
}
|
||||
|
||||
doc.description_html = repl('<table style="width: 100%; table-layout: fixed;">' +
|
||||
'<tr><td style="width:110px"><img src="%(imgurl)s" width="100px"></td>' +
|
||||
'<td>%(desc)s</td></tr>' +
|
||||
'</table>', {
|
||||
imgurl: frappe.utils.get_file_link(doc.image),
|
||||
desc: doc.description.replace(/\n/g, "<br>")});
|
||||
|
||||
refresh_field('description_html');
|
||||
}
|
||||
|
||||
// Quotation to validation - either customer or lead mandatory
|
||||
cur_frm.cscript.weight_to_validate = function(doc, cdt, cdn){
|
||||
if((doc.nett_weight || doc.gross_weight) && !doc.weight_uom) {
|
||||
@ -195,12 +179,4 @@ cur_frm.cscript.copy_from_item_group = function(doc) {
|
||||
|
||||
cur_frm.cscript.image = function() {
|
||||
refresh_field("image_view");
|
||||
|
||||
if(!cur_frm.doc.image) return;
|
||||
|
||||
if(!cur_frm.doc.description_html)
|
||||
cur_frm.cscript.add_image(cur_frm.doc);
|
||||
else {
|
||||
msgprint(__("You may need to update: {0}", [frappe.meta.get_docfield(cur_frm.doc.doctype, "description_html").label]));
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,12 @@
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Unit of measurement of this item (e.g. Kg, Unit, No, Pair).",
|
||||
"fieldname": "stock_uom",
|
||||
@ -112,9 +118,15 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_11",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0,
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"fieldtype": "Text Editor",
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Description",
|
||||
@ -126,10 +138,10 @@
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break0",
|
||||
"fieldname": "column_break_13",
|
||||
"fieldtype": "Column Break",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image",
|
||||
@ -137,7 +149,7 @@
|
||||
"label": "Image",
|
||||
"options": "",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "image_view",
|
||||
@ -146,22 +158,7 @@
|
||||
"label": "Image View",
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "description_html",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Description HTML",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"description": "Generates HTML to include selected image in the description",
|
||||
"fieldname": "add_image",
|
||||
"fieldtype": "Button",
|
||||
"label": "Generate Description HTML",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
"precision": ""
|
||||
},
|
||||
{
|
||||
"fieldname": "variants_section",
|
||||
@ -864,7 +861,7 @@
|
||||
"icon": "icon-tag",
|
||||
"idx": 1,
|
||||
"max_attachments": 1,
|
||||
"modified": "2015-02-05 05:11:39.507487",
|
||||
"modified": "2015-02-10 12:59:15.652054",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Item",
|
||||
|
Loading…
x
Reference in New Issue
Block a user