Item Variant or Use of Rules based on Item Groups

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.



You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Aditya,

This should be possible using a custom script.

Here is a sample:

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

Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.
This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:

Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:

Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 



You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 


Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:

Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 



You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia
100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:


Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 



You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Aditya,

Try using:
doc.item_code += "0" + Math.round(doc.height_dia*100)

M in Math should be in capitals. Also, you don't need to use toFixed as round in javascript gives an integer. (it's a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad...@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += "0" + math.round(doc.height_dia*100).tofixed(0);

Now this code seems to be working

doc.item_code += "0" + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case (“HSS Square Tool Bits 1X”):

Now is it possible to make a case(“HSS Square Tool Bits%”) see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:

Hi Aditya,

Try using:
doc.item_code += “0” + Math.round(doc.height_dia100)

M in Math should be in capitals. Also, you don’t need to use toFixed as round in javascript gives an integer. (it’s a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad…@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case "HSS Square Tool Bits":
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case ("HSS Square Tool Bits 1X"):

Now is it possible to make a case("HSS Square Tool Bits%") see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += "0" + Math.round(doc.height_dia*100)

M in Math should be in capitals. Also, you don't need to use toFixed as round in javascript gives an integer. (it's a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad...@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += "0" + math.round(doc.height_dia*100).tofixed(0);

Now this code seems to be working

doc.item_code += "0" + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality=“H-3X”)
            {
                doc.item_code += “4”;
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:

Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case “HSS Square Tool Bits”:
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case (“HSS Square Tool Bits 1X”):

Now is it possible to make a case(“HSS Square Tool Bits%”) see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += “0” + Math.round(doc.height_dia100)

M in Math should be in capitals. Also, you don’t need to use toFixed as round in javascript gives an integer. (it’s a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad…@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single "=" is used to store a value in the left side variable. So in your code, "H-3X" is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === "H-3X") {
    doc.item_code += "4";
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality="H-3X")
            {
                doc.item_code += "4";
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case "HSS Square Tool Bits":
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case ("HSS Square Tool Bits 1X"):

Now is it possible to make a case("HSS Square Tool Bits%") see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += "0" + Math.round(doc.height_dia*100)

M in Math should be in capitals. Also, you don't need to use toFixed as round in javascript gives an integer. (it's a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad...@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += "0" + math.round(doc.height_dia*100).tofixed(0);

Now this code seems to be working

doc.item_code += "0" + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Anand,

Thanks for pointing out the mistake.

I have noticed one more thing in the the custom script which is being written here, the thing that I have noticed is that the validation is being done only at the time of creating a new item code, but would it be possible to call all the rules when we are editing the existing item codes which would ensure that all fields are as per rules.

On Monday, February 25, 2013 4:53:51 PM UTC+5:30, Anand Doshi wrote:

Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single “=” is used to store a value in the left side variable. So in your code, “H-3X” is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === “H-3X”) {
    doc.item_code += “4”;
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality=“H-3X”)
            {
                doc.item_code += “4”;
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case “HSS Square Tool Bits”:
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case (“HSS Square Tool Bits 1X”):

Now is it possible to make a case(“HSS Square Tool Bits%”) see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += “0” + Math.round(doc.height_dia100)

M in Math should be in capitals. Also, you don’t need to use toFixed as round in javascript gives an integer. (it’s a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad…@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Aditya,

validate and custom_validate get called during each save. I don't see anything which would stop the script from executing after the first save. Maybe this is not the full script?

-Anand.

On 26-Feb-2013, at 1:36 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks for pointing out the mistake.

I have noticed one more thing in the the custom script which is being written here, the thing that I have noticed is that the validation is being done only at the time of creating a new item code, but would it be possible to call all the rules when we are editing the existing item codes which would ensure that all fields are as per rules.

On Monday, February 25, 2013 4:53:51 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single "=" is used to store a value in the left side variable. So in your code, "H-3X" is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === "H-3X") {
    doc.item_code += "4";
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality="H-3X")
            {
                doc.item_code += "4";
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case "HSS Square Tool Bits":
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case ("HSS Square Tool Bits 1X"):

Now is it possible to make a case("HSS Square Tool Bits%") see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += "0" + Math.round(doc.height_dia*100)

M in Math should be in capitals. Also, you don't need to use toFixed as round in javascript gives an integer. (it's a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad...@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += "0" + math.round(doc.height_dia*100).tofixed(0);

Now this code seems to be working

doc.item_code += "0" + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Anand,

I have updated the code which I am working on the gist is same as earlier but has been updated, now I am getting the following error and which means that the custom code is not running.

The problem being faced with the current code is that there is some error in the console which is like:

[15:21:24.490] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2
[15:21:24.541] (new TypeError(“cur_frm.cscript.hide_website_fields is not a function”, “http://test.rigpl.com/js/all-app.min.js”, 2212))

On Clicking the save button I am getting this error

[15:21:58.803] (new ReferenceError(“doc is not defined”, “http://test.rigpl.com/js/all-app.min.js”, 2339))
[15:21:58.833] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2

On Tuesday, February 26, 2013 1:42:58 PM UTC+5:30, Anand Doshi wrote:

Hi Aditya,

validate and custom_validate get called during each save. I don’t see anything which would stop the script from executing after the first save. Maybe this is not the full script?

-Anand.

On 26-Feb-2013, at 1:36 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks for pointing out the mistake.

I have noticed one more thing in the the custom script which is being written here, the thing that I have noticed is that the validation is being done only at the time of creating a new item code, but would it be possible to call all the rules when we are editing the existing item codes which would ensure that all fields are as per rules.

On Monday, February 25, 2013 4:53:51 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single “=” is used to store a value in the left side variable. So in your code, “H-3X” is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === “H-3X”) {
    doc.item_code += “4”;
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality=“H-3X”)
            {
                doc.item_code += “4”;
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case “HSS Square Tool Bits”:
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case (“HSS Square Tool Bits 1X”):

Now is it possible to make a case(“HSS Square Tool Bits%”) see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += “0” + Math.round(doc.height_dia100)

M in Math should be in capitals. Also, you don’t need to use toFixed as round in javascript gives an integer. (it’s a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad…@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Anand,

I have worked out the error so there is no need to check the code. One small thing I wanted to ask since all my code is now almost complete.

I would like to know if I could add custom fields to the Item Group Doc Type, I have seen that this is not possible through any normal user but only through ADMIN user by directly adding fields to the doctype.

I would like to know if this is suggested. I would like to add some custom fields in the item group which define the item group which could then be pulled in the item code itself, thereby decreasing the number of fields in an item to be filled by the user.

On Tuesday, February 26, 2013 3:24:11 PM UTC+5:30, Addy wrote:

Hi Anand,

I have updated the code which I am working on the gist is same as earlier but has been updated, now I am getting the following error and which means that the custom code is not running.

The problem being faced with the current code is that there is some error in the console which is like:

[15:21:24.490] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2
[15:21:24.541] (new TypeError(“cur_frm.cscript.hide_website_fields is not a function”, “http://test.rigpl.com/js/all-app.min.js”, 2212))

On Clicking the save button I am getting this error

[15:21:58.803] (new ReferenceError(“doc is not defined”, “http://test.rigpl.com/js/all-app.min.js”, 2339))
[15:21:58.833] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2

On Tuesday, February 26, 2013 1:42:58 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

validate and custom_validate get called during each save. I don’t see anything which would stop the script from executing after the first save. Maybe this is not the full script?

-Anand.

On 26-Feb-2013, at 1:36 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks for pointing out the mistake.

I have noticed one more thing in the the custom script which is being written here, the thing that I have noticed is that the validation is being done only at the time of creating a new item code, but would it be possible to call all the rules when we are editing the existing item codes which would ensure that all fields are as per rules.

On Monday, February 25, 2013 4:53:51 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single “=” is used to store a value in the left side variable. So in your code, “H-3X” is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === “H-3X”) {
    doc.item_code += “4”;
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality=“H-3X”)
            {
                doc.item_code += “4”;
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case “HSS Square Tool Bits”:
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad…@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case (“HSS Square Tool Bits 1X”):

Now is it possible to make a case(“HSS Square Tool Bits%”) see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += “0” + Math.round(doc.height_dia100)

M in Math should be in capitals. Also, you don’t need to use toFixed as round in javascript gives an integer. (it’s a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad…@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += “0” + math.round(doc.height_dia100).tofixed(0);

Now this code seems to be working

doc.item_code += “0” + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt(“enter item code”);

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad…@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad…@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can’t think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the “default” option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number…


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 

Hi Aditya,

Please update. We have added Item Group into the allowed list for Customize Form.

Thanks,
Anand.

On 26-Feb-2013, at 8:22 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

I have worked out the error so there is no need to check the code. One small thing I wanted to ask since all my code is now almost complete.

I would like to know if I could add custom fields to the Item Group Doc Type, I have seen that this is not possible through any normal user but only through ADMIN user by directly adding fields to the doctype.

I would like to know if this is suggested. I would like to add some custom fields in the item group which define the item group which could then be pulled in the item code itself, thereby decreasing the number of fields in an item to be filled by the user.

On Tuesday, February 26, 2013 3:24:11 PM UTC+5:30, Addy wrote:
Hi Anand,

I have updated the code which I am working on the gist is same as earlier but has been updated, now I am getting the following error and which means that the custom code is not running.

The problem being faced with the current code is that there is some error in the console which is like:

[15:21:24.490] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2
[15:21:24.541] (new TypeError("cur_frm.cscript.hide_website_fields is not a function", "http://test.rigpl.com/js/all-app.min.js", 2212))

On Clicking the save button I am getting this error

[15:21:58.803] (new ReferenceError("doc is not defined", "http://test.rigpl.com/js/all-app.min.js", 2339))
[15:21:58.833] Empty string passed to getElementById(). @ http://test.rigpl.com/lib/js/lib/jquery/jquery.min.js:2

On Tuesday, February 26, 2013 1:42:58 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

validate and custom_validate get called during each save. I don't see anything which would stop the script from executing after the first save. Maybe this is not the full script?

-Anand.

On 26-Feb-2013, at 1:36 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks for pointing out the mistake.

I have noticed one more thing in the the custom script which is being written here, the thing that I have noticed is that the validation is being done only at the time of creating a new item code, but would it be possible to call all the rules when we are editing the existing item codes which would ensure that all fields are as per rules.

On Monday, February 25, 2013 4:53:51 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

A simple error: When comparing two values for equality, use === or == instead of = in javascript.
A single "=" is used to store a value in the left side variable. So in your code, "H-3X" is getting assigned to doc.quality instead of it getting compared for equality.

so your code should be:
if(doc.quality === "H-3X") {
    doc.item_code += "4";
}

Thanks,
Anand.


On 25-Feb-2013, at 4:50 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

I am kind of stuck up with a problem. I am trying to get this validation but the problem is that this validation does not seem to be working.

            if (doc.quality="H-3X")
            {
                doc.item_code += "4";
            }

Now even if the value is different than H-3X the if statement is still run and hence the system is not picking the quality values for some unknown reason. The gist has been pasted and is linked here.

On Tuesday, February 12, 2013 7:38:02 PM UTC+5:30, Anand Doshi wrote:
Dear Aditya,

Try using:
switch(doc.item_group.substr(0, 20)) {
case "HSS Square Tool Bits":
}

Thanks,
Anand.

On 12-Feb-2013, at 7:29 PM, Addy <ad...@gmail.com> wrote:

Hi Anand,

Thanks it worked well, but now I am unable to find a solution to the problem where I need to check only a part of the item group.

Basically I am using this code:

    switch(doc.item_group) {
        case ("HSS Square Tool Bits 1X"):

Now is it possible to make a case("HSS Square Tool Bits%") see the difference, but most of the code for all the groups with this starting are similar therefore I would want to limit my coding to a particular group type. Or is it possible to have a condition on the parent group of an item and still ensure that code is checked for in that item.

Like if I have a code for

Group 1, then how can I ensure that rule is applicable to group 1.1 which is under that group in the group tree or its not possible to write a script for nested groups.

On Monday, February 11, 2013 7:13:44 PM UTC+5:30, Anand Doshi wrote:
Hi Aditya,

Try using:
doc.item_code += "0" + Math.round(doc.height_dia*100)

M in Math should be in capitals. Also, you don't need to use toFixed as round in javascript gives an integer. (it's a bad part of javascript)

Thanks,
Anand.

On 11-Feb-2013, at 4:02 PM, Addy <ad...@gmail.com> wrote:

Hi,

I have solved the problem of exiting the loop by using system.Exit()

But now I am faced with another problem and the problem is that the math feature of java does not seem to be working since there is no response from the system for the code

doc.item_code += "0" + math.round(doc.height_dia*100).tofixed(0);

Now this code seems to be working

doc.item_code += "0" + doc.height_dia*100;

Is there any solution to the above problem?


On Monday, February 11, 2013 2:45:10 PM UTC+5:30, Addy wrote:

Thanks for the help and right guidance. Now I am facing some trouble as I have created a code and the link is this https://gist.github.com/adityaduggal/4753383

The problem is that when a loop is false then I would want that the item code creation is stopped but that does not seem to happen with return false.
Also I would like to get the input values from a user based on the prompt but even that is not happening.

Could some one just point me to the right direction with this code.

On Saturday, February 9, 2013 6:31:45 PM UTC+5:30, Rushabh Mehta wrote:
Check JavaScript prompt function.

Item_code=prompt("enter item code");

Sent from mobile

On 09-Feb-2013, at 3:19 PM, Addy <ad...@gmail.com> wrote:

Dear Rushabh,

I have analysed and tried the code, what I have found out is that the default option would create and item code XX now would it be possible to have an option that by default the USER INPUT is taken as the item code if it is not covered by any rule.



On Tuesday, February 5, 2013 11:45:34 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

Replies below:

On 05-Feb-2013, at 10:20 PM, Addy <ad...@gmail.com> wrote:

Hi Rushabh,

The sample is a great example of how we could control the item codification, but to incorporate all the rules would be one hell of a job or at least it looks like one from the onset.

But its a one time job. Can't think of another way that will give you as much flexibility.

This brings me to another question that when we try to control the item codification from the code, this would mean that the item code would not be entered by the person himself but it would be created by a rule.

Now what if there is no rule written for some item group?
Also would it be possible to have a rule for say group 1 and a rule for group 1.1 and then a rule for group node 1.1.1

For no item group, there is the "default" option. See the script.


Say Group 1 would decide the first letter of the item code
Group 1.1 decided the 2nd letter of the item code
Group 1.1.1 decides the 3rd letter of the item code and so and then some fields in the item code decided the next digits.

But going by what I have always read about item codes, it is always said that some part of your item code should be a serial number followed by a check digit. I am just trying to continue what I had written sometime back on my email.


If you add a sequence number, it will kill your purpose of uniqueness. One way would be to add a custom field for the sequence number, so that you explicitly set the sequence_number..


On Tuesday, February 5, 2013 9:28:55 PM UTC+5:30, Rushabh Mehta wrote:
Aditya,

This should be possible using a custom script.

Here is a sample:


Sorry did not think of it earlier!

best,
Rushabh

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

On 05-Feb-2013, at 5:03 PM, Addy <ad...@gmail.com> wrote:

Hi,

It has been more than 2 years since we are using erpnext and till date I am looking for an answer as to how can I make ITEM CODES for all the items that we manufacture.
The problem is that there are so many variations in my product line that I am confused. Also I would like to follow a system where we could ensure that no item code is created in duplication. I guess that is the essence of an Item Code.

Now to make item codes for all items we would need to ensure that some kind of a rule is followed. Now I have a lot of Item Groups and I would want to define rules for all item groups.

The item groups are like this:

  • All Items
    • Type1
      • Type1.1
        • Type1.1.1
          • ItemCode
          • ItemCode
        • Type1.1.2
      • Type1.2
    • Type2
    • Type3

I would like to define the rules for some of the custom fields and also on the item code. The rules could be like this:

For Item Group Type1.1.1

  1. Item Code Should start with 111
  2. Custom Field1 = XYZ
  3. Custom Field2 = ABC
  4. Custom Field3 = JKL

Is this kind of sophistication possible and if so then could you please let me know how to do the same. I hope I have been able to put forward my query properly.




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 





You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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

 

 




You received this message because you are subscribed to the Google Groups “ERPNext User’s Forum” group.

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

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