Skip to content

Commit

Permalink
improve validator on transaction ref moin move line
Browse files Browse the repository at this point in the history
  • Loading branch information
yk2kus committed May 26, 2016
1 parent 99c6afb commit b30bb34
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions l10n_br_account_banking_payment_cnab/model/payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class PaymentOrder(models.Model):
# warning message
@api.multi
def validate_order(self):
if not len(self.line_ids):
raise Warning("Please select lines to export")
# code must belong to one of allowed code
if self.mode_type.code not in ['240', '400', '500']:
raise Warning("Payment Type Code must be 240, 400 or 500, found %s" % self.mode_type.code)
Expand Down Expand Up @@ -77,6 +79,12 @@ def validate_order(self):
raise Warning("Partner's street not defined")
if not line.move_line_id.transaction_ref:
raise Warning("No transaction reference set for move %s" % line.move_line_id.name)
if len(line.move_line_id.transaction_ref) > 8:
raise Warning("Transaction reference for move line can not be longer than 8 digits found %s" %line.move_line_id.transaction_ref)
try:
int(line.move_line_id.transaction_ref)
except:
raise Warning("Transaction reference for move line must be integer")
if not line.move_line_id.invoice.number:
raise Warning("Null value in 'numero_documento' number not defined for invoice %s" % line.move_line_id.invoice.number)
if len(line.move_line_id.invoice.number) > 10:
Expand Down

0 comments on commit b30bb34

Please sign in to comment.