making validation generic for sales order,sales invoice,purchase order etc.

This commit is contained in:
Anurag Mishra 2018-11-26 15:19:17 +05:30
parent 6ddb15b3df
commit e657fe84b8
3 changed files with 7 additions and 8 deletions

View File

@ -57,6 +57,8 @@ class AccountsController(TransactionBase):
_('{0} is blocked so this transaction cannot proceed'.format(supplier_name)), raise_exception=1)
def validate(self):
self.validate_qty_is_not_zero()
if self.get("_action") and self._action != "update_after_submit":
self.set_missing_values(for_validate=True)
@ -359,6 +361,11 @@ class AccountsController(TransactionBase):
return gl_dict
def validate_qty_is_not_zero(self):
for item in self.items:
if not item.qty:
frappe.throw("Item quantity can not be zero")
def validate_account_currency(self, account, account_currency=None):
valid_currency = [self.company_currency]
if self.get("currency") and self.currency != self.company_currency:

View File

@ -32,7 +32,6 @@ class SalesOrder(SellingController):
def validate(self):
super(SalesOrder, self).validate()
self.validate_order_type()
self.validate_delivery_date()
self.validate_proj_cust()

View File

@ -98,7 +98,6 @@ class DeliveryNote(SellingController):
frappe.throw(_("Sales Order required for Item {0}").format(d.item_code))
def validate(self):
self.validate_qty()
self.validate_posting_time()
super(DeliveryNote, self).validate()
self.set_status()
@ -120,11 +119,6 @@ class DeliveryNote(SellingController):
self.update_current_stock()
if not self.installation_status: self.installation_status = 'Not Installed'
def validate_qty(self):
for item in self.items:
if not item.qty:
frappe.throw("Item quantity can not be zero")
def validate_with_previous_doc(self):
super(DeliveryNote, self).validate_with_previous_doc({
@ -208,7 +202,6 @@ class DeliveryNote(SellingController):
def on_submit(self):
self.validate_packed_qty()
self.validate_qty()
# Check for Approving Authority
frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype, self.company, self.base_grand_total, self)