Server-side template & custom javascript function

Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.


Note:

If you are posting an issue,

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/d6e56933-3011-4bc3-ab09-73d0ee396ca2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

On 23-Aug-2014, at 8:19 am, Nonnatee Kanjana no...@ps-groups.com wrote:

Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.

Why don’t you share what you have done so far?


Note:

If you are posting an issue,

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/d6e56933-3011-4bc3-ab09-73d0ee396ca2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Note:

If you are posting an issue,

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/04C7099D-019E-4F2F-970E-B6152EB0FD1C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Hi,

The print format code can be found here
The javascript for printing amount in word for Thai land is not very sophisticated. But readable.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/2a271cb1-1d37-413e-adca-d3e595a1489b%40googlegroups.com.

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

hi,


My post reply seem to disappear. nvm, here is the paste bin of the print format 
The javascript and css are not very sophisticated. 

Thanks. 

On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1203a45a-abc9-47ca-8da9-da03ce36f8db%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
So where are you stuck? What is your error message?



On 24-Aug-2014, at 3:15 pm, Nonnatee Kanjana <no...@ps-groups.com> wrote:

hi,

My post reply seem to disappear. nvm, here is the paste bin of the print format 
The javascript and css are not very sophisticated. 

Thanks. 

On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.

-- 
Note:
 
If you are posting an issue,
 
1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
2. 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.
3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
4. 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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/1203a45a-abc9-47ca-8da9-da03ce36f8db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/661E0378-CB13-4667-99CB-A93BA3B09DCA%40gmail.com.

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

Their is  no error msg. I just can’t get any javascript inside the <script> tag to execute.

eg. 

  1.                     <td class=“field_label” width=“20%”>{{ _("Total of ") }}</td>
  2.                     <td class=“field_label” style=“text-align: center; width: 35%;”>
  3.                         <div><script> (doc.entries.length) </script> &nbsp;
  4.                             <script>if (doc.entries.length > 1){ (‘items.’)}else{ (‘item.’)}</script> -</div>
  5.                         <div><i style=“color:lightgray;”>(E. &amp;O. E)</i></div>
  6.                     </td>
or
  1. <script>                    ThaiBaht(format_currency(doc.grand_total_export, doc.currency), doc.currency)
  2. </script>
 


On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/5536e88d-fa49-4060-b202-bb740c375062%40googlegroups.com.

    For more options, visit https://groups.google.com/d/optout.
Why don't you generate your formats server side?


On 27-Aug-2014, at 2:29 am, Nonnatee Kanjana <no...@ps-groups.com> wrote:

Their is  no error msg. I just can’t get any javascript inside the <script> tag to execute.
eg. 

  1.                     <td class="field_label" width="20%">{{ _("Total of ") }}</td>
  2.                     <td class="field_label" style="text-align: center; width: 35%;">
  3.                         <div><script> (doc.entries.length) </script> &nbsp;
  4.                             <script>if (doc.entries.length > 1){ ('items.')}else{ ('item.')}</script> -</div>
  5.                         <div><i style="color:lightgray;">(E. &amp;O. E)</i></div>
  6.                     </td>
or
  1. <script>                    ThaiBaht(format_currency(doc.grand_total_export, doc.currency), doc.currency)
  2. </script>
 


On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/5536e88d-fa49-4060-b202-bb740c375062%40googlegroups.com.

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



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/77EF3F96-35AB-4579-94F1-74200D17E2C8%40gmail.com.

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

Not sure where to start. could you point me the right direction. so I could finally contribute. 

On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cbe7f230-a2d0-4a8c-935a-a046f0f8c54b%40googlegroups.com.

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

On 27-Aug-2014, at 1:08 pm, Nonnatee Kanjana <no...@ps-groups.com> wrote:

hi,

Not sure where to start. could you point me the right direction. so I could finally contribute. 

mm - you will have to make this function translatable (add the _() to the strings) - then you can use it.


On Saturday, August 23, 2014 9:49:00 AM UTC+7, Nonnatee Kanjana wrote:
Hi,
I have a javascript function to print amount in word for Thai lang. However, I cant seem to get it to work together with print format using server-side template. Plz help.



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/cbe7f230-a2d0-4a8c-935a-a046f0f8c54b%40googlegroups.com.

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



Note:

 

If you are posting an issue,

 

  1. ERPNext is a free and open source software and support is given on this forum by a team (https://frappe.io/webnotes). So please consider donating if you find this forum useful (https://frappe.io/buy). Even a small amount would be helpful.
  2. 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.
  3. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  4. 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+un…@googlegroups.com.

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/E96C7CCF-967F-42E8-B625-D9A92DD708F9%40gmail.com.

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

hi,

is this still supported or is there a information on that topic?
I may want to include javascript in server-side template as well…is there a way?

Best,
Daniel

Don’t know any way to include client side javascript in server side print format code. May be using javascript, you should calculate the value and save the value in a field. Later you can use that field in server side print format. Otherwise, you can write the function in python.

Hi, I managed to do a JS…but somehow it is not properly working:

http://pastebin.com/4jwFiAW5

Edit: //
Basically I understood now the big problem that Jinja executes the code server-sides and the JS is executed client-sides…this is why I am getting errors…

Best,
Daniel

I have successfully call / executes JS function in server-side print format template. code can be found here. JS function call are made between line #446 - #450.