refactor: Folio no validation

This commit is contained in:
Suraj Shetty 2020-05-03 19:10:02 +05:30
parent 268df35d80
commit 9fffe254fc

View File

@ -168,10 +168,12 @@ class ShareTransfer(Document):
return 'Outside'
def folio_no_validation(self):
shareholders = ['from_shareholder', 'to_shareholder']
shareholders = [shareholder for shareholder in shareholders if self.get(shareholder) is not '']
for shareholder in shareholders:
doc = self.get_shareholder_doc(self.get(shareholder))
shareholder_fields = ['from_shareholder', 'to_shareholder']
for shareholder_field in shareholder_fields:
shareholder_name = self.get(shareholder_field)
if not shareholder_name:
continue
doc = self.get_shareholder_doc(shareholder_name)
if doc.company != self.company:
frappe.throw(_('The shareholder does not belong to this company'))
if not doc.folio_no: