Custom Script help: requiring Material Request reference for specific condition

My intension to require a user to have a Material Request referenced in each stock entry line item (in Stock
Entry Details table) based on the following conditions:

1. purpose is material receipt
2. receiving location is Warehouse X (a specific warehouse)

In other words, for the specific Warehouse X, the user must create the Stock Entry from a Material Request if it is receiving via purpose material receipt. 

The script logic is to compare the # of line items vs the number of line items with a Material Request referenced. If # of lines > than lines with Material Request, the form should not save.

This is the more complete script: http://pastebin.com/Z3YJ52Se

Unfortunately, I think there is something wrong with the script as it makes saving the form not possible.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



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

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

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b247c936-41ea-45d3-93ba-9b6068e8e725%40googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
I have added an example in github wiki. Please check https://github.com/frappe/frappe/wiki/Client-side-scripting#wiki-material-receipt-in-warehousex-must-be-made-against-material-request

On 25-Feb-2014, at 10:54 am, lxnow <la...@union.ph> wrote:

My intension to require a user to have a Material Request referenced in each stock entry line item (in Stock
Entry Details table) based on the following conditions:

1. purpose is material receipt
2. receiving location is Warehouse X (a specific warehouse)

In other words, for the specific Warehouse X, the user must create the Stock Entry from a Material Request if it is receiving via purpose material receipt. 

The script logic is to compare the # of line items vs the number of line items with a Material Request referenced. If # of lines > than lines with Material Request, the form should not save.

This is the more complete script: http://pastebin.com/Z3YJ52Se

Unfortunately, I think there is something wrong with the script as it makes saving the form not possible.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



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

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

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b247c936-41ea-45d3-93ba-9b6068e8e725%40googlegroups.com.

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



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



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

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

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/16F65262-789E-4B69-BC70-3B8E394485C6%40gmail.com.

    For more options, visit https://groups.google.com/groups/opt_out.
Thanks Nabin. Example works, but I had to add a closing parenthesis; have edited the wiki. And at least for hosted accounts, frappe.model.get doesn't work yet, so using wn.model.get instead.

On Tuesday, February 25, 2014 3:15:02 PM UTC+8, Nabin Hait wrote:
I have added an example in github wiki. Please check https://github.com/frappe/frappe/wiki/Client-side-scripting#wiki-material-receipt-in-warehousex-must-be-made-against-material-request

On 25-Feb-2014, at 10:54 am, lxnow <la...@union.ph> wrote:

My intension to require a user to have a Material Request referenced in each stock entry line item (in Stock
Entry Details table) based on the following conditions:

1. purpose is material receipt
2. receiving location is Warehouse X (a specific warehouse)

In other words, for the specific Warehouse X, the user must create the Stock Entry from a Material Request if it is receiving via purpose material receipt. 

The script logic is to compare the # of line items vs the number of line items with a Material Request referenced. If # of lines > than lines with Material Request, the form should not save.

This is the more complete script: http://pastebin.com/Z3YJ52Se

Unfortunately, I think there is something wrong with the script as it makes saving the form not possible.



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



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

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

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/b247c936-41ea-45d3-93ba-9b6068e8e725%40googlegroups.com.

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



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



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

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

    To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-developer-forum/a97e97a6-9ae2-4793-8150-64ca791200ec%40googlegroups.com.

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