Need to force users to enter amount > 0 in the item rate in sales orders

40 views
Skip to first unread message

HF

unread,
Mar 5, 2014, 5:39:34 AM3/5/14
to erpnext-dev...@googlegroups.com
Hi;

I need to force users to enter amount>0 in the sales order items, how can I do this ??

rushabh

unread,
Mar 7, 2014, 12:28:27 AM3/7/14
to erpnext-dev...@googlegroups.com
You can add a client script

cur_frm.cscript.validate = function(doc) {
  if(doc.value <= 0) {
     msgprint("Please enter a value for X");
     throw, "X required";

HF

unread,
Mar 9, 2014, 8:11:56 AM3/9/14
to erpnext-dev...@googlegroups.com
How this will affect every line in the sales items ??

rushabh

unread,
Mar 10, 2014, 2:55:52 AM3/10/14
to erpnext-dev...@googlegroups.com
sorry you can try this;

cur_frm.cscript.validate = function(doc) {
  $.each(wn.model.get("Sales Order Item", {parent:doc.name}), function(i, d) {
    if(d.amount <= 0) {
      msgprint("Please enter a value for X for item " + d.item_code);
      throw, "X required";
    }

HF

unread,
Mar 10, 2014, 5:05:10 AM3/10/14
to erpnext-dev...@googlegroups.com
Please check the syntax, it doesn't work !!!

Nabin Hait

unread,
Mar 10, 2014, 6:07:02 AM3/10/14
to erpnext-dev...@googlegroups.com
cur_frm.cscript.validate = function(doc) {
  $.each(wn.model.get("Sales Order Item", {parent:doc.name}), function(i, d) {
    if(d.amount <= 0) {
      msgprint("Please enter a value for X for item " + d.item_code);
      throw, "X required";
    }
  })
}

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

HF

unread,
Mar 10, 2014, 8:57:43 AM3/10/14
to erpnext-dev...@googlegroups.com
Hi Nabin;

It is not working ??


Anand Doshi

unread,
Mar 10, 2014, 12:52:53 PM3/10/14
to ERPNext Developer's Forum


On Mon, Mar 10, 2014 at 6:27 PM, HF <gm.h....@gmail.com> wrote:
Hi Nabin;

It is not working ??


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

HF

unread,
Mar 11, 2014, 4:16:17 AM3/11/14
to erpnext-dev...@googlegroups.com
It doen't work;

I think i and d variables are not defined for the function to work properly !!


HF

unread,
Mar 27, 2014, 4:03:52 AM3/27/14
to erpnext-dev...@googlegroups.com
Hi;

I found the correct solution as the below code, it works fine.

cur_frm.cscript.custom_validate = function(doc) {
    var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
for(var i = 0; i<cl.length; i++){
amt = flt(cl[i].amount);
      if(amt==0) {
        msgprint("Zero Value not allowed in any line of Sales Order, Please correct.");
        return false;
        }
}
}


Reply all
Reply to author
Forward
0 new messages