[fix] [minor] fixed validation in production order

This commit is contained in:
Nabin Hait 2013-07-31 11:07:17 +05:30
parent 18b1e202d5
commit 69843a2e4e

View File

@ -19,7 +19,7 @@ import webnotes
from webnotes.utils import cstr, flt, nowdate from webnotes.utils import cstr, flt, nowdate
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
from webnotes import msgprint from webnotes import msgprint, _
sql = webnotes.conn.sql sql = webnotes.conn.sql
@ -63,8 +63,8 @@ class DocType:
def validate_production_order_against_so(self): def validate_production_order_against_so(self):
# already ordered qty # already ordered qty
ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order` ordered_qty_against_so = webnotes.conn.sql("""select sum(qty) from `tabProduction Order`
where production_item = %s and sales_order = %s and docstatus < 2""", where production_item = %s and sales_order = %s and docstatus < 2 and name != %s""",
(self.doc.production_item, self.doc.sales_order))[0][0] (self.doc.production_item, self.doc.sales_order, self.doc.name))[0][0]
total_qty = flt(ordered_qty_against_so) + flt(self.doc.qty) total_qty = flt(ordered_qty_against_so) + flt(self.doc.qty)
@ -80,11 +80,11 @@ class DocType:
so_qty = flt(so_item_qty) + flt(dnpi_qty) so_qty = flt(so_item_qty) + flt(dnpi_qty)
if total_qty > so_qty: if total_qty > so_qty:
webnotes.msgprint("""Total production order qty for item: %s against sales order: %s \ webnotes.msgprint(_("Total production order qty for item") + ": " +
will be %s, which is greater than sales order qty (%s). cstr(self.doc.production_item) + _(" against sales order") + ": " +
Please reduce qty or remove the item.""" % cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " +
(self.doc.production_item, self.doc.sales_order, _("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" +
total_qty, so_qty), raise_exception=1) _("Please reduce qty."), raise_exception=1)
def stop_unstop(self, status): def stop_unstop(self, status):