image field in sales order item

90 views
Skip to first unread message

Satish

unread,
Apr 3, 2014, 1:10:49 AM4/3/14
to erpnext-u...@googlegroups.com
Dear All,

Is it possible that a custom image field be created in Sales Order Item for which we can add an image while creating Sales Order?

This would be useful where the products are engineer to order and a generic item has been created. At the time of finalization of order we could attach the image file just for reference. This particular image may not be useful for any further orders and remains specific to the Sales Order only.

Regards
Satish

Maxwell Morais

unread,
Apr 3, 2014, 7:30:39 AM4/3/14
to erpnext-u...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/bfc37fd6-a0ff-484e-826b-44b087410aa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Best Regards.

Maxwell Morais
Python Developer powered by Webnotes framework <3

Satish

unread,
Apr 4, 2014, 1:39:01 AM4/4/14
to erpnext-u...@googlegroups.com
Thanks Maxwell.
It is a nice way to attach files.

However, I would like that the attached images show in the list as the Item images are shown in sales order.
For that I suppose I would need to generate an HTML description similar to the one generated in Item Master.

Could you guide me to achieve that?

Regards
Satish


On Thursday, 3 April 2014 17:00:39 UTC+5:30, Maxwell wrote:
2014-04-03 2:10 GMT-03:00 Satish <satishgu...@gmail.com>:
Dear All,

Is it possible that a custom image field be created in Sales Order Item for which we can add an image while creating Sales Order?

This would be useful where the products are engineer to order and a generic item has been created. At the time of finalization of order we could attach the image file just for reference. This particular image may not be useful for any further orders and remains specific to the Sales Order only.

Regards
Satish

--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.

Satish

unread,
Apr 4, 2014, 1:54:48 AM4/4/14
to erpnext-u...@googlegroups.com
Update!

I created a new field with field type "small text" .
Then went to the sales order and manually typed  <img src="files/name.jpg" width="100px">  and voila, I could see the image right there.
So now I just need to find a way to generate the HTML code automatically which can show the uploaded file.

Would be great if you could help out.

Regards
Satish

Rushabh Mehta

unread,
Apr 4, 2014, 5:21:48 AM4/4/14
to erpnext-u...@googlegroups.com
You can easily write a custom script for that!

Satish

unread,
Apr 4, 2014, 8:08:32 AM4/4/14
to erpnext-u...@googlegroups.com
Well that's the problem.
I don't have any technical background and have absolutely no idea about writing scripts.

However, I think I found the script being used in Item Master for generating HTML description:


// for description from attachment
// takes the first attachment and creates
// a table with both image and attachment in HTML
// in the "alternate_description" field
cur_frm.cscript.add_image = function(doc, dt, dn) {
if(!doc.image) {
msgprint(wn._('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: wn.utils.get_file_link(doc.image), desc:doc.description});

refresh_field('description_html');
}


Do you think this would work for me, with some changes?


Regards
Satish

Satish

unread,
Apr 10, 2014, 10:38:44 AM4/10/14
to erpnext-u...@googlegroups.com
I have created 3 custom fields in doctype  "Sales Order Item"

1.   image          option: attach_files:       Field type: Select
2.  ref_image                                         Field type: Small Text
3. attach_image                                    Field type: Button


and I have the following custom script



cur_frm.cscript.attach_image = function(doc, dt, dn) {
if(!doc.image) {
msgprint(wn._('Please select an "Image" first'));
return;
}

doc.ref_image = repl('<table style="width: 100%; table-layout: fixed;">'+
'<tr><td style="width:110px"><img src="%(imgurl)s" width="100px"></td>'+
'</table>', {imgurl: wn.utils.get_file_link(doc.image)});

refresh_field('ref_image');
}




The script is not working. When I click the button nothing happens.
I suspect something is wrong with the script. 
I must mention that I have no idea about writing scripts but I have tried using the script of similar function being used elsewhere in erpnext.
What I am trying to achieve could be understood by reading previous post in this thread.
Could someone please point out the mistake in the script? I somehow feel that it would work with little correction.

Regards
Satish
Reply all
Reply to author
Forward
0 new messages