Queries regarding Custom Scripts

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as “READ-ONLY” but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 

Aditya,

Check the first example:

https://github.com/webnotes/wnframework/wiki/Client-side-scripting

You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:

Aditya,

Check the first example:


You can also use this to set the “hidden” property of docfield (df).

best,
Rushabh



W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 

Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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

 

 

Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:

Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/_NwD8nc5whMJ.

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

 

 

Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?

  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/lwS2q8ekAscJ.

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

 

 

Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:

  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/nHJ4XJft13MJ.

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

 

 

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:

Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 

Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 



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 post to this group, send email to er...@googlegroups.com.

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

 

 

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:

Use this in custom_validate

if(cur_frm.doc._islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad…@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom
validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 



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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 




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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 



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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 



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 post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group…please don’t tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:

Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label “Naming Series” and field type = “Data”.
It will create a field with field name = “naming_series”. (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - “#List/Property Setter”.
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an…@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It’s one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad…@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc._islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad…@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom
validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 

Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657

Regards,
Nabin Hait

On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Nabin,

Thanks for the gist, now I would need to do some searching on Python but before I do that I think with new updates the option to create server side scripting has been disabled. Kindly let me know how could I create custom script on server side.

On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:

Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657


Regards,
Nabin Hait


On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ScRmI7L155YJ.

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

 

 

Hi Nabin,

Tried to run this code on my test account and I am getting a error in loading a script whch says “Error in script while loading” when I click on an item. The error code I am getting is as below:

[13:43:06.051] Traceback (innermost last):
  File “…/lib/webnotes/widgets/form/load.py”, line 83, in load_single_doc
    dl = webnotes.bean(dt, dn).doclist
  File “…/lib/webnotes/init.py”, line 307, in bean
    return Bean(doctype, name)
  File “…/lib/webnotes/model/bean.py”, line 54, in init
    self.load_from_db(dt, dn)
  File “…/lib/webnotes/model/bean.py”, line 80, in load_from_db
    self.run_method(“onload”)
  File “…/lib/webnotes/model/bean.py”, line 214, in run_method
    self.make_obj()
  File “…/lib/webnotes/model/bean.py”, line 103, in make_obj
    self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist)
  File “…/lib/webnotes/init.py”, line 292, in get_obj
    return get_obj(dt, dn, doc, doclist, with_children)
  File “…/lib/webnotes/model/code.py”, line 156, in get_obj
    return get_server_obj(doc, doclist)
  File “…/lib/webnotes/model/code.py”, line 108, in get_server_obj
    exec custom_class + custom_script.replace(‘\t’,’  ') in locals()
  File “<string>”, line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + ‘a’ * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Traceback (innermost last):
  File “…/lib/webnotes/handler.py”, line 156, in handle
    execute_cmd(cmd)
  File “…/lib/webnotes/handler.py”, line 191, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File “…/lib/webnotes/handler.py”, line 208, in call
    return fn(**newargs)
  File “…/lib/webnotes/widgets/form/load.py”, line 43, in getdoc
    doclist = load_single_doc(doctype, name, user or webnotes.session.user)
  File “…/lib/webnotes/widgets/form/load.py”, line 87, in load_single_doc
    raise e
  File “<string>”, line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + ‘a’ * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Also I would like to ask a few more questions:

  1. if it is possible to fetch the field entered by the user in the server script then I would easily be able to generate the item code.
  2. how could I change the above code to only generate 3-digit series only using numbers 1-9 and capital letters. Please note that I am planning to omit the following characters from the item code 0 (Zero), I and O.

I am sorry to ask so many simple questions since this is the first time I have had my tryst with Python code anyhow I have already started to read about python code as well now. Hope you would show me the right path to follow.



On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657


Regards,
Nabin Hait


On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/j6djbjQFl9wJ.

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

 

 

Hi Aditya,

In python, "Indentation" is very important, based on that it decide the block of statements. Please check the indentation.

And you should use either Space or Tab, for indentation.

You can fetch any value entered by the user in server script, using self.doc.fieldname

Excluding uppercase letters and I, O, 0 is very difficult to implement, it breaks normal alphanumeric addition. Regarding 3 digit naming, you are entering the serial no in item group manually, so try to limit to 3 digit there.



Regards,
Nabin Hait

On 09-Apr-2013, at 1:51 PM, Aditya Duggal wrote:

Hi Nabin,

Tried to run this code on my test account and I am getting a error in loading a script whch says "Error in script while loading" when I click on an item. The error code I am getting is as below:

[13:43:06.051] Traceback (innermost last):
  File "../lib/webnotes/widgets/form/load.py", line 83, in load_single_doc
    dl = webnotes.bean(dt, dn).doclist
  File "../lib/webnotes/__init__.py", line 307, in bean
    return Bean(doctype, name)
  File "../lib/webnotes/model/bean.py", line 54, in __init__
    self.load_from_db(dt, dn)
  File "../lib/webnotes/model/bean.py", line 80, in load_from_db
    self.run_method("onload")
  File "../lib/webnotes/model/bean.py", line 214, in run_method
    self.make_obj()
  File "../lib/webnotes/model/bean.py", line 103, in make_obj
    self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist)
  File "../lib/webnotes/__init__.py", line 292, in get_obj
    return get_obj(dt, dn, doc, doclist, with_children)
  File "../lib/webnotes/model/code.py", line 156, in get_obj
    return get_server_obj(doc, doclist)
  File "../lib/webnotes/model/code.py", line 108, in get_server_obj
    exec custom_class + custom_script.replace('\t','  ') in locals()
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Traceback (innermost last):
  File "../lib/webnotes/handler.py", line 156, in handle
    execute_cmd(cmd)
  File "../lib/webnotes/handler.py", line 191, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File "../lib/webnotes/handler.py", line 208, in call
    return fn(**newargs)
  File "../lib/webnotes/widgets/form/load.py", line 43, in getdoc
    doclist = load_single_doc(doctype, name, user or webnotes.session.user)
  File "../lib/webnotes/widgets/form/load.py", line 87, in load_single_doc
    raise e
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Also I would like to ask a few more questions:
  1. if it is possible to fetch the field entered by the user in the server script then I would easily be able to generate the item code.
  2. how could I change the above code to only generate 3-digit series only using numbers 1-9 and capital letters. Please note that I am planning to omit the following characters from the item code 0 (Zero), I and O.

I am sorry to ask so many simple questions since this is the first time I have had my tryst with Python code anyhow I have already started to read about python code as well now. Hope you would show me the right path to follow.



On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657

Regards,
Nabin Hait

On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/j6djbjQFl9wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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

 

 

Hi Nabin,

I have been able to get rid of the error, thanks you for the code. I think there seems to be a problem with the next serial code since my item codes are not getting the next serial number after the code. Also I have added the code to add a check digit at the end of the item code which might be creating some problem kindly let me know what have I done wrong. I have updated the gist with a fork here.

On Tuesday, April 9, 2013 5:29:46 PM UTC+5:30, Nabin Hait wrote:

Hi Aditya,

In python, “Indentation” is very important, based on that it decide the block of statements. Please check the indentation.

And you should use either Space or Tab, for indentation.

You can fetch any value entered by the user in server script, using self.doc.fieldname

Excluding uppercase letters and I, O, 0 is very difficult to implement, it breaks normal alphanumeric addition. Regarding 3 digit naming, you are entering the serial no in item group manually, so try to limit to 3 digit there.




Regards,
Nabin Hait


On 09-Apr-2013, at 1:51 PM, Aditya Duggal wrote:

Hi Nabin,

Tried to run this code on my test account and I am getting a error in loading a script whch says "Error in script while loading" when I click on an item. The error code I am getting is as below:

[13:43:06.051] Traceback (innermost last):
  File "../lib/webnotes/widgets/form/load.py", line 83, in load_single_doc
    dl = webnotes.bean(dt, dn).doclist
  File "../lib/webnotes/__init__.py", line 307, in bean
    return Bean(doctype, name)
  File "../lib/webnotes/model/bean.py", line 54, in __init__
    self.load_from_db(dt, dn)
  File "../lib/webnotes/model/bean.py", line 80, in load_from_db
    self.run_method("onload")
  File "../lib/webnotes/model/bean.py", line 214, in run_method
    self.make_obj()
  File "../lib/webnotes/model/bean.py", line 103, in make_obj
    self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist)
  File "../lib/webnotes/__init__.py", line 292, in get_obj
    return get_obj(dt, dn, doc, doclist, with_children)
  File "../lib/webnotes/model/code.py", line 156, in get_obj
    return get_server_obj(doc, doclist)
  File "../lib/webnotes/model/code.py", line 108, in get_server_obj
    exec custom_class + custom_script.replace('\t','  ') in locals()
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Traceback (innermost last):
  File "../lib/webnotes/handler.py", line 156, in handle
    execute_cmd(cmd)
  File "../lib/webnotes/handler.py", line 191, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File "../lib/webnotes/handler.py", line 208, in call
    return fn(**newargs)
  File "../lib/webnotes/widgets/form/load.py", line 43, in getdoc
    doclist = load_single_doc(doctype, name, user or webnotes.session.user)
  File "../lib/webnotes/widgets/form/load.py", line 87, in load_single_doc
    raise e
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Also I would like to ask a few more questions:
  1. if it is possible to fetch the field entered by the user in the server script then I would easily be able to generate the item code.
  2. how could I change the above code to only generate 3-digit series only using numbers 1-9 and capital letters. Please note that I am planning to omit the following characters from the item code 0 (Zero), I and O.

I am sorry to ask so many simple questions since this is the first time I have had my tryst with Python code anyhow I have already started to read about python code as well now. Hope you would show me the right path to follow.



On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657

Regards,
Nabin Hait

On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 





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 post to this group, send email to erpnext-dev…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/j6djbjQFl9wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/c1XaihIBQ9sJ.

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

 

 

Is it possible to make a field mandatory based on its visibility? I have certain fields which become hidden or visible based on eval property of customise form view.

Now what I want is that a field becomes mandatory if it is visible. Kindly let me know if this kind of a thing is possible.

On Tuesday, April 9, 2013 10:48:34 PM UTC+5:30, Aditya Duggal wrote:

Hi Nabin,

I have been able to get rid of the error, thanks you for the code. I think there seems to be a problem with the next serial code since my item codes are not getting the next serial number after the code. Also I have added the code to add a check digit at the end of the item code which might be creating some problem kindly let me know what have I done wrong. I have updated the gist with a fork here.

On Tuesday, April 9, 2013 5:29:46 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

In python, “Indentation” is very important, based on that it decide the block of statements. Please check the indentation.

And you should use either Space or Tab, for indentation.

You can fetch any value entered by the user in server script, using self.doc.fieldname

Excluding uppercase letters and I, O, 0 is very difficult to implement, it breaks normal alphanumeric addition. Regarding 3 digit naming, you are entering the serial no in item group manually, so try to limit to 3 digit there.




Regards,
Nabin Hait


On 09-Apr-2013, at 1:51 PM, Aditya Duggal wrote:

Hi Nabin,

Tried to run this code on my test account and I am getting a error in loading a script whch says "Error in script while loading" when I click on an item. The error code I am getting is as below:

[13:43:06.051] Traceback (innermost last):
  File "../lib/webnotes/widgets/form/load.py", line 83, in load_single_doc
    dl = webnotes.bean(dt, dn).doclist
  File "../lib/webnotes/__init__.py", line 307, in bean
    return Bean(doctype, name)
  File "../lib/webnotes/model/bean.py", line 54, in __init__
    self.load_from_db(dt, dn)
  File "../lib/webnotes/model/bean.py", line 80, in load_from_db
    self.run_method("onload")
  File "../lib/webnotes/model/bean.py", line 214, in run_method
    self.make_obj()
  File "../lib/webnotes/model/bean.py", line 103, in make_obj
    self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist)
  File "../lib/webnotes/__init__.py", line 292, in get_obj
    return get_obj(dt, dn, doc, doclist, with_children)
  File "../lib/webnotes/model/code.py", line 156, in get_obj
    return get_server_obj(doc, doclist)
  File "../lib/webnotes/model/code.py", line 108, in get_server_obj
    exec custom_class + custom_script.replace('\t','  ') in locals()
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Traceback (innermost last):
  File "../lib/webnotes/handler.py", line 156, in handle
    execute_cmd(cmd)
  File "../lib/webnotes/handler.py", line 191, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File "../lib/webnotes/handler.py", line 208, in call
    return fn(**newargs)
  File "../lib/webnotes/widgets/form/load.py", line 43, in getdoc
    doclist = load_single_doc(doctype, name, user or webnotes.session.user)
  File "../lib/webnotes/widgets/form/load.py", line 87, in load_single_doc
    raise e
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Also I would like to ask a few more questions:
  1. if it is possible to fetch the field entered by the user in the server script then I would easily be able to generate the item code.
  2. how could I change the above code to only generate 3-digit series only using numbers 1-9 and capital letters. Please note that I am planning to omit the following characters from the item code 0 (Zero), I and O.

I am sorry to ask so many simple questions since this is the first time I have had my tryst with Python code anyhow I have already started to read about python code as well now. Hope you would show me the right path to follow.



On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657

Regards,
Nabin Hait

On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/j6djbjQFl9wJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hE_NskWxJ5YJ.

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

 

 

Hi Aditya,

Why not shift the conditions from depends_on to custom script? That way you can specify to display and make it mandatory in one shot.

Thanks,
Anand.

On 17-Apr-2013, at 1:42 PM, Aditya Duggal <ad...@gmail.com> wrote:

Is it possible to make a field mandatory based on its visibility? I have certain fields which become hidden or visible based on eval property of customise form view.

Now what I want is that a field becomes mandatory if it is visible. Kindly let me know if this kind of a thing is possible.

On Tuesday, April 9, 2013 10:48:34 PM UTC+5:30, Aditya Duggal wrote:
Hi Nabin,

I have been able to get rid of the error, thanks you for the code. I think there seems to be a problem with the next serial code since my item codes are not getting the next serial number after the code. Also I have added the code to add a check digit at the end of the item code which might be creating some problem kindly let me know what have I done wrong. I have updated the gist with a fork here.

On Tuesday, April 9, 2013 5:29:46 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

In python, "Indentation" is very important, based on that it decide the block of statements. Please check the indentation.

And you should use either Space or Tab, for indentation.

You can fetch any value entered by the user in server script, using self.doc.fieldname

Excluding uppercase letters and I, O, 0 is very difficult to implement, it breaks normal alphanumeric addition. Regarding 3 digit naming, you are entering the serial no in item group manually, so try to limit to 3 digit there.



Regards,
Nabin Hait

On 09-Apr-2013, at 1:51 PM, Aditya Duggal wrote:

Hi Nabin,

Tried to run this code on my test account and I am getting a error in loading a script whch says "Error in script while loading" when I click on an item. The error code I am getting is as below:

[13:43:06.051] Traceback (innermost last):
  File "../lib/webnotes/widgets/form/load.py", line 83, in load_single_doc
    dl = webnotes.bean(dt, dn).doclist
  File "../lib/webnotes/__init__.py", line 307, in bean
    return Bean(doctype, name)
  File "../lib/webnotes/model/bean.py", line 54, in __init__
    self.load_from_db(dt, dn)
  File "../lib/webnotes/model/bean.py", line 80, in load_from_db
    self.run_method("onload")
  File "../lib/webnotes/model/bean.py", line 214, in run_method
    self.make_obj()
  File "../lib/webnotes/model/bean.py", line 103, in make_obj
    self.obj = webnotes.get_obj(doc=self.doc, doclist=self.doclist)
  File "../lib/webnotes/__init__.py", line 292, in get_obj
    return get_obj(dt, dn, doc, doclist, with_children)
  File "../lib/webnotes/model/code.py", line 156, in get_obj
    return get_server_obj(doc, doclist)
  File "../lib/webnotes/model/code.py", line 108, in get_server_obj
    exec custom_class + custom_script.replace('\t','  ') in locals()
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Traceback (innermost last):
  File "../lib/webnotes/handler.py", line 156, in handle
    execute_cmd(cmd)
  File "../lib/webnotes/handler.py", line 191, in execute_cmd
    ret = call(method, webnotes.form_dict)
  File "../lib/webnotes/handler.py", line 208, in call
    return fn(**newargs)
  File "../lib/webnotes/widgets/form/load.py", line 43, in getdoc
    doclist = load_single_doc(doctype, name, user or webnotes.session.user)
  File "../lib/webnotes/widgets/form/load.py", line 87, in load_single_doc
    raise e
  File "<string>", line 29
    return strip_zs[:-1] + chr(ord(strip_zs[-1]) + 1) + 'a' * (len(s) - len(strip_zs))
         ^
 IndentationError: expected an indented block

Also I would like to ask a few more questions:
  1. if it is possible to fetch the field entered by the user in the server script then I would easily be able to generate the item code.
  2. how could I change the above code to only generate 3-digit series only using numbers 1-9 and capital letters. Please note that I am planning to omit the following characters from the item code 0 (Zero), I and O.

I am sorry to ask so many simple questions since this is the first time I have had my tryst with Python code anyhow I have already started to read about python code as well now. Hope you would show me the right path to follow.



On Tuesday, April 2, 2013 11:45:01 PM UTC+5:30, Nabin Hait wrote:
Hi Aditya,

Instead of doing client side scripting, if you do it in server side script (python), then life will be lot easier. 

I have made a gist, it will do the trick, please check this link https://gist.github.com/nabinhait/5294657

Regards,
Nabin Hait

On 02-Apr-2013, at 8:31 PM, Aditya Duggal wrote:

Hi Anand,

Thanks for the earlier suggestion of after save it works as always. As for the naming series system, I have come up with a new naming system which is very small, I am more inclined in using the  3 digits for the serial number so that the item code remains small. My target is to get the item codes to less than 10-digits or at max 10 digits with a check digit for which I would be posting a query.

I guess with these constraints I cannot go for numeric serial number since 5-digit numeric serial number only saves 99,999 records whereas with alphanumeric series I could save 46,656 (36^3) records in just 3 digits. Also I am planning to remove the confusing letters or digits vis-a-vis I,O and 0. Which means I can store upto 35,937 (33^3) records in 3 digit serial number.

Also this new item coding which I am planning should be sufficient for my company even if we go beyond a million item codes and I am hoping that this project of sorts would be a one time effort for a long time to come. I am planning to share this thing in a blog once I am satisfied with things since with my case I am the coder and the user as well.

I hope there must be a way to manage the series via item group.....please don't tell me that it is not possible since I am banking on this part of the code and I am continuing my work, hoping that I would get a solution from your end in a day or two.


On Tuesday, April 2, 2013 8:09:11 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Scratch that. I think I have a better solution to your item code woes. It is about playing a trick on the naming series system. 

Hopefully, it should work. You can try this out in your test environment:

1. Create a custom field in item with label "Naming Series" and field type = "Data".
It will create a field with field name = "naming_series". (You may mark it as Mandatory after testing if it works)

2. In your URL, type this after app.html - "#List/Property Setter".
Click on New to create a new Property Setter and enter the following:
DocType or Field = DocType
DocType = Item
Property = auto name
Property Type = Data
Set Value = naming_series:

make sure to type that colon at the end of naming_series

Save this Property Setter

3. So now that the ground is set, all you have to do is before saving (in custom_validate), make sure that Naming Series is set to your codification system like ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-
and when saving, it will keep track of the number for that series ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-

So, if you are saving the first item of the series, ITEM_GROUP_NAME-SOME_OTHER_VARIABLE- then it will be named as ITEM_GROUP_NAME-SOME_OTHER_VARIABLE-00001

The only constraint here is that the number will be of 5 digits, since this is the way naming series works in ERPNext.

I think it is a better way to keep track of your series instead of updating Item Group after saving every Item.

Hope this helps.

Thanks,
Anand.


On 02-Apr-2013, at 7:48 PM, Anand Doshi <an...@iwebnotes.com> wrote:

Hi Aditya 

Developer documentation needs a lot of work. It's one of the items which we are gonna take up next since auto inventory accounting is almost done. 

I think you can try using 

cur_frm.cscript.after_save = function() {

}

I am not so sure about it. Will need to check the code since it is rarely used. 

Sent from my phone

On 02-Apr-2013, at 7:27 PM, Aditya Duggal <ad...@gmail.com> wrote:

Thanks Anand for the quick response. Works like a jiffy.

Also where can I access all the coding options of wnframework since I need to know if I could control a code to run only after successful saving of a document since my counter seems to be running even if there is an error in saving a new document.

On Tuesday, April 2, 2013 6:42:01 PM UTC+5:30, Anand Doshi wrote:
Use this in custom_validate

if(cur_frm.doc.__islocal) {
    // your code here
}

Sent from my phone

On 02-Apr-2013, at 6:38 PM, Aditya Duggal <ad...@gmail.com> wrote:

Another thing I wanted to know which is not mentioned in the wiki is that what code should I use if I want a code to be initiated only at the time of creating a document currently I am using some code under

cur_frm.cscript.custom_validate = function(doc) {

But this code also runs if I make some changes to an existing document, whereas my need is to run some particular code only at the time of creation of the document.

Is there any solution for that?

On Tuesday, April 2, 2013 12:07:50 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I have update the code in the gist the updated code is here. Now the code is working fine but the only things which are not working are:
  • I am unable to fetch Serial Number properly from the Item Group in a Item Code
  • Unable to update the serial number in the item group of the item.
  • Also I am facing a peculiar problem, if for some reason the item is not saved the counter of the serial number still keeps on running so if the serial number is 111 and if we face the did not save error for 3 times then the next time the serial number becomes 115 instead of 111. So the code is not exiting at the time of the did not save.

Kindly please help me with the small modifications so that I could continue with my work.


On Monday, April 1, 2013 6:39:47 PM UTC+5:30, Aditya Duggal wrote:
Hi,

I am almost there with this custom script and its understanding but currently I am having an issue with the client side script. Can you please let me know what is the error in this client script

What is this script doing?
  • Fetch values from the item group selected line 1~8
  • Function to generate the alphanumeric key line 11~17
  • Code to disable fields after saving line 19~24
  • Fetch the field serial_number mentioned in the item group selected and then assign the item code with that serial number line 26~48
  • Update the serial number with the next value in the series in the ITEM GROUP which has been selected line 50~56

Kindly let me know what is wrong with the code since I am unable to perform the tasks mentioned in the code.


On Monday, April 1, 2013 4:23:14 PM UTC+5:30, Aditya Duggal wrote:
Thanks Nabin

I have one more query which I have posted in stackoverflow maybe it might interest you regarding the creation of an alphanumeric key, the link for the question is this

On Monday, April 1, 2013 4:07:14 PM UTC+5:30, Nabin Hait wrote:
Hi,

You can set the returned value in callback function, I had updated the wiki (https://github.com/webnotes/wnframework/wiki/Client-side-scripting#get-values-from-server). 


Regards,
Nabin Hait

On 01-Apr-2013, at 3:53 PM, Aditya Duggal wrote:

Hi Rushabh,

Thanks for the code.

But one more thing which seems to be missing is that there is no code to know how to update the field value in a particular form.

I would be able to fetch a value from the item group via the code mentioned here

But what if  I need to update that value to a new updated value, the code for that is not mentioned in the scripting.


On Wednesday, February 27, 2013 11:14:12 AM UTC+5:30, rushabh wrote:
Aditya,

Check the first example:


You can also use this to set the "hidden" property of docfield (df).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

On 25-Feb-2013, at 4:08 PM, Aditya Duggal <ad...@gmail.com> wrote:

Hi,

I have some queries with regards to custom scripts:

  1. I am trying to make certain fields in the item master as "READ-ONLY" but after the creation of item codes. Since my item codes would be dependent on these fields and to maintain the integrity of the items I would like to lock these fields using the custom script. Kindly let me know how to achieve this by using custom reports.
  2. Is there a way to show certain fields on screen at the time of item creation since they are the ones according to which the item code is created, something on the lines of the item variant which is long pending but now I am trying to prepare one myself.





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/roI6wXRFBVIJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/6hzY3kKbh2wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/ZGBnYH_wwqYJ.

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

 

 




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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/9TcI6_rISQgJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/rbEqd-nTW40J.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/j6djbjQFl9wJ.

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

 

 





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 post to this group, send email to er…@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/hE_NskWxJ5YJ.

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

 

 




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 post to this group, send email to er...@googlegroups.com.

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