Extended code not working

hi,

I’ve extended code of some documents, for example sales order:
I created new file in custom app, imported SalesOrder class and overridded the validate function and called the class in the custom hooks.

default code from erpnext:


def validate(self):
	super(SalesOrder, self).validate()
	self.validate_delivery_date()
	self.validate_proj_cust()
	self.validate_po()
	self.validate_uom_is_integer("stock_uom", "stock_qty")
	self.validate_uom_is_integer("uom", "qty")
	self.validate_for_items()
	self.validate_warehouse()
	self.validate_drop_ship()
	self.validate_serial_no_based_delivery()
	validate_inter_company_party(self.doctype, self.customer, self.company, self.inter_company_order_reference)

	if self.coupon_code:
		from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code
		validate_coupon_code(self.coupon_code)

	from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
	make_packing_list(self)

	self.validate_with_previous_doc()
	self.set_status()

	if not self.billing_status: self.billing_status = 'Not Billed'
	if not self.delivery_status: self.delivery_status = 'Not Delivered'

	self.reset_default_field_value("set_warehouse", "items", "warehouse")

what i did is for example:


def validate(self):
	frappe.throw("testing.")
	super(SalesOrder, self).validate()
	self.validate_delivery_date()
	self.validate_proj_cust()
	self.validate_po()
	self.validate_uom_is_integer("stock_uom", "stock_qty")
	self.validate_uom_is_integer("uom", "qty")
	self.validate_for_items()
	self.validate_warehouse()
	self.validate_drop_ship()
	self.validate_serial_no_based_delivery()
	validate_inter_company_party(self.doctype, self.customer, self.company, self.inter_company_order_reference)

	if self.coupon_code:
		from erpnext.accounts.doctype.pricing_rule.utils import validate_coupon_code
		validate_coupon_code(self.coupon_code)

	from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
	make_packing_list(self)

	self.validate_with_previous_doc()
	self.set_status()

	if not self.billing_status: self.billing_status = 'Not Billed'
	if not self.delivery_status: self.delivery_status = 'Not Delivered'

	self.reset_default_field_value("set_warehouse", "items", "warehouse")

but the frappe.throw("testing.") not working on all time i save, its only working after doing saving 3,4 times.

example: i clicked save btn and its working throwing error "Testing" and again i click save, it will allow to save, then again and again it will allow to save, but after 3,4 times its validating, very confusing.