image field in Sales Order Item

321 views
Skip to first unread message

Satish

unread,
Apr 12, 2014, 12:31:29 AM4/12/14
to erpnext-dev...@googlegroups.com
Hi

I have already asked it on Users forum but only now I realize that this may be the right place to post it.

I am trying to add an Image field to Sales Order Item to attach images specific the order only. This may be useful while doing custom work where creation of a new item may feel unnecessary and the image could be added in the order iteself just for the reference. So I feel that the approach being used in Item master could be used here i.e. we attach a photograph, write the description and then generate HTML description combining both.

To achieve this, 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 and have tried using the script being used in item master in erpnext.

Could someone please point out the mistake in the script? I somehow feel that it would work with little correction.

Further, to avoid another ref_image field which would take up another column in the sales order item table, is it possible to replace the contents of the description field with the HTML description containing both description and image??

Regards
Satish

Maxwell Morais

unread,
Apr 12, 2014, 2:33:50 AM4/12/14
to erpnext-dev...@googlegroups.com
Hi, Satish!

You are using a custom script in Setup, or you modified the "sales_order.js" ?


--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/9bfca4c4-3741-4310-b67a-7d375e5958ab%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 12, 2014, 3:50:23 AM4/12/14
to erpnext-dev...@googlegroups.com
I am using a custom script in Setup

Regards
Satish
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Satish

unread,
Apr 14, 2014, 5:52:11 AM4/14/14
to erpnext-dev...@googlegroups.com
Can someone help??

Regards

Maxwell Morais

unread,
Apr 14, 2014, 9:17:17 AM4/14/14
to erpnext-dev...@googlegroups.com
When you open the form with custom code, are showed any message on browser console?


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/41925dc7-7d6d-486e-8b20-8b9114741c98%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Satish

unread,
Apr 14, 2014, 9:49:18 AM4/14/14
to erpnext-dev...@googlegroups.com
Hi

When I just open the form no message in shown in console.
However, when I attach an image and press the button to generate HTML description i get the following in the console:

Traceback (innermost last): File "lib/webnotes/handler.py", line 78, in handle execute_cmd(cmd) File "lib/webnotes/handler.py", line 118, in execute_cmd ret = call(method, webnotes.form_dict) File "lib/webnotes/handler.py", line 140, in call return fn(**newargs) File "lib/webnotes/handler.py", line 22, in runserverobj webnotes.widgets.form.run_method.runserverobj() File "lib/webnotes/widgets/form/run_method.py", line 40, in runserverobj r = webnotes.model.code.run_server_obj(so, method, arg) File "lib/webnotes/model/code.py", line 104, in run_server_obj raise Exception, 'No method %s' % method_name Exception: No method


Can someone help??

Regards
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsubscr...@googlegroups.com.



--

Best Regards.

Maxwell Morais
Python Developer powered by Webnotes framework <3

--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Maxwell Morais

unread,
Apr 14, 2014, 10:04:35 AM4/14/14
to erpnext-dev...@googlegroups.com

​Y​
our code can not be running for a reference error, such as a simple spelling error, the button is labeled “atach_image” and you put in your code “attach_image”.

Or something is preventing the loading of custom code, to verify this, go to “Setup”> “Custom Code” and add the line below before the “cur_frm.cscript.attach_image”
console.log (" Custom code working fine ") and check if the message are Showed in browser console When You refresh the page.



To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/c2a9be68-5327-429c-9f0f-59f76a16fb56%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Satish

unread,
Apr 18, 2014, 9:09:26 AM4/18/14
to erpnext-dev...@googlegroups.com
Hi Maxwell,

Thanks for the help and sorry for replying late.

I think you are right. The custom code doesn't seem to be loading. I added the line as suggested by you and refreshed the page. I got the following output in the console window:

Error: Invalid value for <svg> attribute preserveAspectRatio="xMidyMid meet" app.html:26
Cleared localstorage all-app.min.js:162
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery.min.js:2
Cleared Cache - New Metadata all-app.min.js:363
Starting up... all-app.min.js:2425
Error: Invalid value for <svg> attribute preserveAspectRatio="xMidyMid meet" app/images/splash.svg:15
Attr.specified is deprecated. Its value is always true.



what could this error mean??

Regards



--

Best Regards.

Maxwell Morais
Python Developer powered by Webnotes framework <3

--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

rushabh

unread,
Apr 21, 2014, 2:40:11 AM4/21/14
to erpnext-dev...@googlegroups.com
There does not seem to be any error. If you console messages do no show up, its because the script is not being triggered.

What type of field is "attach_image" ? Are you sure the spelling is correct?

Satish

unread,
Apr 23, 2014, 12:27:56 AM4/23/14
to erpnext-dev...@googlegroups.com
Hi Rushabh,

Thanks for replying.
I have rechecked the fields, names and spellings. I don't see anything wrong. 
attach_image is a button field. No other configuration.





Regards

Satish

unread,
Apr 28, 2014, 12:07:18 AM4/28/14
to erpnext-dev...@googlegroups.com
Any guidance?

Regards
Satish Gupta

Maxwell Morais

unread,
Apr 28, 2014, 6:29:21 AM4/28/14
to erpnext-dev...@googlegroups.com
Satish, maybe the Custom Scripts is not loaded because an unreported error.

Try add you custom code on sales_order.js, if you have access to the access code.


--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/74036215-c732-435a-8bcf-6448d30ef383%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Satish

unread,
Apr 29, 2014, 12:47:19 AM4/29/14
to erpnext-dev...@googlegroups.com
Thanks for replying Maxwell.
How do I add code sales_order.js??

Regards
Satish Gupta
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Anand Doshi

unread,
Apr 29, 2014, 3:56:27 AM4/29/14
to Satish, erpnext-dev...@googlegroups.com

Hi Satish,

One possibility of script not loading could be that you have multiple client scripts for the same doctype and it is loding the other one.


Thanks,
Anand Doshi.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/6ece7991-e7e2-404d-976a-ea5800ff86c7%40googlegroups.com.

Satish

unread,
Apr 29, 2014, 10:07:55 AM4/29/14
to erpnext-dev...@googlegroups.com, Satish
Hi Anand,

This is the only custom script I have. There are no other scripts.
However, your comment set me thinking that should the script be associated with doctype  Sales Order Item   or should it be on doctype  Sales Order?

Regards
Satish

rushabh

unread,
Apr 30, 2014, 1:17:13 AM4/30/14
to erpnext-dev...@googlegroups.com, Satish
Sales Order - Custom scripts are not executed for Table DocTypes

Satish

unread,
Apr 30, 2014, 2:10:21 AM4/30/14
to erpnext-dev...@googlegroups.com, Satish
Thanks Rushabh.
I think there is some progress. I changed the doctype to Sales Order.
Now I can see in the console that the script is loading. However, now when I click on the button it gives an error saying  "Please select an "Image" first".  The image is already selected.
What could be wrong?

Regards
Satish Gupta

rushabh

unread,
May 1, 2014, 12:46:18 AM5/1/14
to erpnext-dev...@googlegroups.com, Satish
Can you share your latest script via pastebin?

Also can you check whether the property exists via checking "cur_frm.doc.image" from your js console?

Satish

unread,
May 1, 2014, 2:51:18 AM5/1/14
to erpnext-dev...@googlegroups.com, Satish
The pastebin url is    http://pastebin.com/HfaLqmhZ

I am not sure how to check if the property exists or not....but I did type "cur_frm.doc.image"  without quotes in the console and it returned "underfied"
However, console is showing undefined for all the fields of the  "Sales Order Item". It is showing only the fields on the form Sales Order.
So it means  "Sales Order Item" subform needs to be accessed first to access all its fields. But I am not aware how to do that. 

Regards
Satish Gupta

rushabh

unread,
May 1, 2014, 7:57:51 AM5/1/14
to erpnext-dev...@googlegroups.com, Satish
If you are in child doc,

start your function with

child = locals[dt][dn];

and check child.image

Satish

unread,
May 5, 2014, 1:02:27 AM5/5/14
to erpnext-dev...@googlegroups.com, Satish
Thanks for replying.

Sorry to drag it on but I can't seem to get the child reference right. 
I have tried child.image but it returns undefined.

I have tried   "cur_frm.fields_dict.sales_order_details"    but past this I can't get the fields list inside the sales_order_details table. I have searched internet but couldn't get the proper references to be used.


Regards
Satish Gupta

rushabh

unread,
May 6, 2014, 12:33:12 AM5/6/14
to erpnext-dev...@googlegroups.com, Satish
the parameters dt, dn are the reference to the child record on the trigger

to get access to the child document you can use locals[dt][dn]

what do you get as dt, dn and locals[dt][dn]?

that should help you.

Satish

unread,
May 6, 2014, 1:58:42 AM5/6/14
to erpnext-dev...@googlegroups.com, Satish
Hi

I have changed my script to the following:

// for image from attachment
// takes the selected image and creates
// a table with image in HTML
// in the "ref_image" field

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

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

refresh_field('ref_image');
}


But I am getting the following error:


Traceback (innermost last): File "lib/webnotes/handler.py", line 78, in handle execute_cmd(cmd) File "lib/webnotes/handler.py", line 118, in execute_cmd ret = call(method, webnotes.form_dict) File "lib/webnotes/handler.py", line 140, in call return fn(**newargs) File "lib/webnotes/handler.py", line 22, in runserverobj webnotes.widgets.form.run_method.runserverobj() File "lib/webnotes/widgets/form/run_method.py", line 40, in runserverobj r = webnotes.model.code.run_server_obj(so, method, arg) File "lib/webnotes/model/code.py", line 104, in run_server_obj raise Exception, 'No method %s' % method_name Exception: No method 



Regards
Satish Gupta

rushabh

unread,
May 7, 2014, 12:21:56 AM5/7/14
to erpnext-dev...@googlegroups.com, Satish
The trace is from an unrelated error. Do you get the value of d correct? try printing it out on console.log(d)

Satish

unread,
May 7, 2014, 1:34:13 AM5/7/14
to erpnext-dev...@googlegroups.com, Satish
Hi

I have added line   'console.log(d)'    after   defining   'var d'   but I don't get any output in the console. As I press the button I get the same error as earlier.
Directly typing  console.log(d)  in the console window returns that   d is not defined.

Another interesting thing I noticed is that even if I remove the script and I press the button, I get the same error as told in earlier post. So it seems to me that pressing the button doesn't even trigger the script. It is as if the script doesn't exist at all. Though not sure but I think the reference of attach_image button needs to be changed in the begging of the script. which means the line

"cur_frm.doc.attach_image"    needs to be changed to something else. This seems to be pointing to a field which doesn't exist. The field "attach_image" actually exists on the child table  sales_order_details


Regards
Satish Gupta

rushabh

unread,
May 7, 2014, 1:44:05 AM5/7/14
to erpnext-dev...@googlegroups.com, Satish
yes your custom script is not being executed/

If there is a field called "attach_image" in both parent and child, I think it will not execute for child. Can you name your child field differently ?


On Wednesday, May 7, 2014 11:04:13 AM UTC+5:30, Satish wrote:
Hi

Satish

unread,
May 7, 2014, 1:55:39 AM5/7/14
to erpnext-dev...@googlegroups.com, Satish
There is no custom field on main form. Neither is there any field with the same name. Also I have tried changing the field name but no success.
Don't you think the  reference   cur_frm.doc.attach_image   needs to be changed to something else?? Will it work even for the field on child table if there is no similarly named field on main form??

Regards
Satish Gupta

Satish

unread,
May 19, 2014, 10:41:10 AM5/19/14
to erpnext-dev...@googlegroups.com, Satish
Hi

I have come back to this thread after a lot of searching and trials but without success. Can someone give me pointers in what I want to achieve? This is really important for us. 

Regards
Satish Gupta

Rushabh Mehta

unread,
May 19, 2014, 11:54:57 AM5/19/14
to erpnext-dev...@googlegroups.com
Satish,

I am unable to follow what trials you are doing. You need to share your scripts so that we know what you are doing.



@rushabh_mehta

--
Note:
 
If you are posting an issue,
1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.
 
End of Note
---
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/99c149ea-93b1-4bc0-9c0d-7de78aef793c%40googlegroups.com.

Satish

unread,
May 22, 2014, 5:02:38 AM5/22/14
to erpnext-dev...@googlegroups.com
Hi

I am taking the script I earlier shared as the base and making small changes to it to see the effect. I am assuming that the script is basically correct and I just need to make some changes to control references to get it right. The link to script is   http://pastebin.com/HfaLqmhZ  
I may be grossly wrong and if I am please do indicate. Then I might stop banging my head over it.

1. First of all if I start the script with    cur_frm.doc.add_new_image (i have changed the custom field names)   instead of   cur_frm.cscript.add_new_image  the script is not triggered at all. I gives the following error:

Traceback (innermost last): File "lib/webnotes/handler.py", line 78, in handle execute_cmd(cmd) File "lib/webnotes/handler.py", line 118, in execute_cmd ret = call(method, webnotes.form_dict) File "lib/webnotes/handler.py", line 140, in call return fn(**newargs) File "lib/webnotes/handler.py", line 22, in runserverobj webnotes.widgets.form.run_method.runserverobj() File "lib/webnotes/widgets/form/run_method.py", line 40, in runserverobj r = webnotes.model.code.run_server_obj(so, method, arg) File "lib/webnotes/model/code.py", line 104, in run_server_obj raise Exception, 'No method %s' % method_name Exception: No method


2. When I use cur_frm.cscript.add_new_image it returns "Please select and image first" even though the image is already selected.

3. If I declare a variable d with var d = locals(dt, dn) then it gives the following error:

  1. Uncaught TypeError: object is not a function VM325:1698
    1. cur_frm.cscript.add_new_imageVM325:1698
    2. wn.ui.form.ScriptManager.Class.extend.triggerall-app.min.js:2078
    3. wn.ui.form.ControlButton.wn.ui.form.ControlData.extend.onclickall-app.min.js:2134
    4. (anonymous function)all-app.min.js:2134
    5. b.event.dispatchjquery.min.js:2
    6. v.handle

4. If I declare variable using  var d = locals[dt][dn]   then nothing happens. I click the button and no error is shown either in pop-up or in console.

5. If I declare variable using poing 4  and remove   dt, dn   from   function i.e.   cur_frm.cscript.add_new_image = function (doc)  then I get the following error:

  1. Uncaught ReferenceError: dt is not defined VM492:1698
    1. cur_frm.cscript.add_new_imageVM492:1698
    2. wn.ui.form.ScriptManager.Class.extend.triggerall-app.min.js:2078
    3. wn.ui.form.ControlButton.wn.ui.form.ControlData.extend.onclickall-app.min.js:2134
    4. (anonymous function)all-app.min.js:2134
    5. b.event.dispatchjquery.min.js:2
    6. v.handle

6. Taking a clue from error in point 5, I tried replacing dt with "Sales Order". But now it says dn is not defined

7. Now if I replace dn with "SO/14-15/00041" it again starts giving me an error that "Please select an image first".

8. I went through the Client Side Cookbook and used doc.doctype and doc.docname in place of dt and dn but get the following error:

  1. Uncaught TypeError: Cannot read property 'new_image' of undefined VM678:1699
    1. cur_frm.cscript.add_new_imageVM678:1699
    2. wn.ui.form.ScriptManager.Class.extend.triggerall-app.min.js:2078
    3. wn.ui.form.ControlButton.wn.ui.form.ControlData.extend.onclickall-app.min.js:2134
    4. (anonymous function)all-app.min.js:2134
    5. b.event.dispatchjquery.min.js:2
    6. v.handle

9. Similarly searching through forums and google searches I have been trying to make changes to the top 3 lines of the script but with same results.

So this is basically what I have been trying without success. Any pointers from this point forward?

Regards


@rushabh_mehta

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+unsub...@googlegroups.com.

Rushabh Mehta

unread,
May 22, 2014, 8:34:51 AM5/22/14
to erpnext-dev...@googlegroups.com
Hi

I am taking the script I earlier shared as the base and making small changes to it to see the effect. I am assuming that the script is basically correct and I just need to make some changes to control references to get it right. The link to script is   http://pastebin.com/HfaLqmhZ  
I may be grossly wrong and if I am please do indicate. Then I might stop banging my head over it.


doc will never work in the child table. Are you running this on a child table or main form?


1. First of all if I start the script with    cur_frm.doc.add_new_image (i have changed the custom field names)   instead of   cur_frm.cscript.add_new_image  the script is not triggered at all. I gives the following error:

Traceback (innermost last): File "lib/webnotes/handler.py", line 78, in handle execute_cmd(cmd) File "lib/webnotes/handler.py", line 118, in execute_cmd ret = call(method, webnotes.form_dict) File "lib/webnotes/handler.py", line 140, in call return fn(**newargs) File "lib/webnotes/handler.py", line 22, in runserverobj webnotes.widgets.form.run_method.runserverobj() File "lib/webnotes/widgets/form/run_method.py", line 40, in runserverobj r = webnotes.model.code.run_server_obj(so, method, arg) File "lib/webnotes/model/code.py", line 104, in run_server_obj raise Exception, 'No method %s' % method_name Exception: No method



Seems unrelated

2. When I use cur_frm.cscript.add_new_image it returns "Please select and image first" even though the image is already selected.

3. If I declare a variable d with var d = locals(dt, dn) then it gives the following error:

  1. Uncaught TypeError: object is not a function VM325:1698
    1. cur_frm.cscript.add_new_imageVM325:1698
    2. wn.ui.form.ScriptManager.Class.extend.triggerall-app.min.js:2078
    3. wn.ui.form.ControlButton.wn.ui.form.ControlData.extend.onclickall-app.min.js:2134
    4. (anonymous function)all-app.min.js:2134
    5. b.event.dispatchjquery.min.js:2
    6. v.handle


Seems like an error in the script. Click on the VM325:1698 and see where it is stuck.

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/851006d3-d192-415c-948e-c6a76c021d75%40googlegroups.com.

Satish

unread,
May 22, 2014, 9:14:24 AM5/22/14
to erpnext-dev...@googlegroups.com
Hi

I have all three of my custom fields on child table "Sales Order Item" under the main form "Sales Order". So maybe that explains why doc won't work.
However, I have associated the script with Doctype "Sales Order" and not "Sales Order Item" as you said earlier that the script needs to be associated with the main form only.

Clicking on VM325:1698 doesn't help. It just shows the my written script. Nothing else.

Regards
Satish Gupta

Rushabh Mehta

unread,
May 22, 2014, 9:26:40 AM5/22/14
to erpnext-dev...@googlegroups.com


Hi

I have all three of my custom fields on child table "Sales Order Item" under the main form "Sales Order". So maybe that explains why doc won't work.
However, I have associated the script with Doctype "Sales Order" and not "Sales Order Item" as you said earlier that the script needs to be associated with the main form only.

Clicking on VM325:1698 doesn't help. It just shows the my written script. Nothing else.

Which line does it show the error in?

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/26a3e4f2-4350-4407-806c-9f8930757b4b%40googlegroups.com.

Satish

unread,
May 22, 2014, 9:40:40 AM5/22/14
to erpnext-dev...@googlegroups.com
Well a white highlighter blinks once on the line  var d = locals(dt, dn);

Regards
Satish Gupta

Rushabh Mehta

unread,
May 22, 2014, 9:41:31 AM5/22/14
to erpnext-dev...@googlegroups.com
should be 

d = locals[dt][dn]



@rushabh_mehta

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b9f9621c-b97f-445c-8ad3-b2c531d78498%40googlegroups.com.

Satish

unread,
May 22, 2014, 10:00:38 AM5/22/14
to erpnext-dev...@googlegroups.com
I have changed   var d = locals(dt, dn)   to    d = locals[dt][dn]

Now it is not doing anything. Not even an error.

Regards
Satish 
should be 

Rushabh Mehta

unread,
May 22, 2014, 10:02:37 AM5/22/14
to erpnext-dev...@googlegroups.com
Satish,

It is really hard to visualize to me what you are trying to do, others please try. I would recommend that you hire a freelancer to help you out.

best,
Rushabh



@rushabh_mehta

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/580dcec1-2cd0-45c0-9e0b-0d9980f6b81d%40googlegroups.com.

Satish

unread,
May 23, 2014, 1:46:52 AM5/23/14
to erpnext-dev...@googlegroups.com
Ok. Let me make one last attempt to explain what I am trying to achieve.

When entering a Sales Order, as soon as an Item is selected in  Sales Order Details, the details of the item are fetched from the Item master and the description field is populated with  <img src="file/xxx.jpg> and other details. This shows the related photograph of the item which was attached when creating item master.

Now lets say while creating an item in item master no photograph was selected, I want to add a functionality that the image can be attached at the time of entering order details. I just want to populate the description field with  <img src="file/xxx.jpg"> and other details at the time of entering order details. This gives me the flexibility to add a different image for same item in different orders. 


Regards
Satish Gupta



@rushabh_mehta

Satish

unread,
May 30, 2014, 2:18:51 AM5/30/14
to erpnext-dev...@googlegroups.com
Finally some good news. 
In one of the earlier posts when I said that nothing worked when I used  var d = locals[dt][dn]  , it seems that it was actually working and it was just a matter of saving (or refreshing it).
So here is the final code which is working for me


Please note that I have done away with the field  reference_image  which I was earlier using to show the new image. I am now using the existing description field to show the custom image with the description. However, in this case if the description field already contains HTML code, I have to delete the HTML part manually and only keep the text description before I can click the button add_new_image otherwise everything will get garbled up. But this is good enough for me.

So now I have two custom fields named 'new_image' which is a select field with option 'attach_files:' and 'add_new_image' field which is a button field which actually triggers the javascript code. 
Running the code takes the description from the description field and takes the newly attached image, creates an HTML description and replaces the contents in the description field. So I can now change the image in the description field when I am entering a new order without needing to change the image in the item master.

Thanks all for great support.

Regards
Satish Gupta
Reply all
Reply to author
Forward
0 new messages