html item desc removed from item master, item image added in oppurtunity
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index a0ebcce..8f93b2d 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -94,8 +94,21 @@
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');
+ }
+ }
+ })
}
}
diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py
index 31af3cd..39dd614 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.py
+++ b/erpnext/crm/doctype/opportunity/opportunity.py
@@ -59,18 +59,6 @@
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 @@
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):
diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.json b/erpnext/selling/doctype/opportunity_item/opportunity_item.json
index b6527e0..d81b1b7 100644
--- a/erpnext/selling/doctype/opportunity_item/opportunity_item.json
+++ b/erpnext/selling/doctype/opportunity_item/opportunity_item.json
@@ -15,6 +15,11 @@
"reqd": 0
},
{
+ "fieldname": "col_break1",
+ "fieldtype": "Column Break",
+ "permlevel": 0
+ },
+ {
"fieldname": "item_name",
"fieldtype": "Data",
"in_list_view": 1,
@@ -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",
@@ -69,6 +75,29 @@
"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",
"in_list_view": 0,
@@ -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",
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 4e82c55..af7e7f0 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -150,22 +150,6 @@
}
}
-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.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]));
- }
}
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 36d2109..c2f2a9b 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -80,6 +80,12 @@
"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",
"fieldtype": "Link",
@@ -113,8 +119,14 @@
"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",