Add "before_validate" hook to document.py (#6112)

Reference: https://discuss.erpnext.com/t/override-default-validation/20622/5

The addition of a `before_validate` hook makes it possible to override validation methods. This feature has been requested in numerous threads. See:
https://discuss.erpnext.com/t/override-controllers-events/25723/2
https://discuss.erpnext.com/t/is-method-overriding-in-frappe-possible/9225/19
https://discuss.erpnext.com/t/how-to-override-method-in-frappe/28786/8
This commit is contained in:
theopen-institute 2018-09-24 12:50:39 +05:45 committed by Rushabh Mehta
parent 80e5ae54b3
commit ce6446adc2

View file

@ -875,9 +875,11 @@ class Document(BaseDocument):
return
if self._action=="save":
self.run_method("before_validate")
self.run_method("validate")
self.run_method("before_save")
elif self._action=="submit":
self.run_method("before_validate")
self.run_method("validate")
self.run_method("before_submit")
elif self._action=="cancel":