def on_description__validate(self, entry, value): if value is None: return ValidationError(_("Description must be filled in"))
def on_p_cred_sn_valid_until__validate(self, widget, value): if not self.p_cred_sn.get_value(): return if value <= datetime.date.today(): return ValidationError(_(u"This date must be set in the future."))
def on_quantity__validate(self, widget, value): if not value or value <= 0: return ValidationError(_(u'This quantity should be positive.'))
def on_invoice_number__validate(self, widget, value): if not 0 < value <= 999999999: return ValidationError( _("Invoice number must be between 1 and 999999999"))
def on_code__validate(self, widget, value): # FIXME: Consider the branch in this check if self.model.check_unique_value_exists(self.model_type.code, value): return ValidationError(_("Code already in use"))
def on_on_sale_price__validate(self, entry, value): if value < 0: return ValidationError(_("Sale price can not be 0"))
def _on_bank_account__validate(self, entry, value, bank_info): if bank_info: try: bank_info.validate_field(value) except BoletoException as e: return ValidationError(str(e))
def on_estimated_start__validate(self, widget, value): if (self._new_model and value < localtoday() and not api.sysparam.get_bool('ALLOW_OUTDATED_OPERATIONS')): return ValidationError(u"The start date cannot be on the past") self.estimated_finish.validate(force=True)
def on_end_date__validate(self, widget, date): if date > datetime.date.today(): return ValidationError(_("End date must be less than today")) if date < self.model.start_date: self.start_date.set_date(date)
def on_max_installments__validate(self, widget, value): if value <= 0: return ValidationError(_(u'The value must be positive.'))
def on_quantity__validate(self, entry, value): if value <= 0: return ValidationError("The quantity must be greater than 0") return self._validate_quantity(value)
def on_penalty__validate(self, widget, value): if value < 0: return ValidationError(_(u'The value must be positive.'))
def on_daily_interest__validate(self, widget, value): if value < 0: return ValidationError(_(u'The value must be positive.'))
def on_value__validate(self, entry, value): if value <= 0: return ValidationError(_("Value must be greater than zero"))
def on_expire_date__validate(self, widget, value): # open_date has a seconds precision, so that why we are rounding it to # date here. if value.date() < self.model.open_date.date(): msg = _(u"The expire date must be after the sale open date") return ValidationError(msg)
def on_start_reductions_number__validate(self, widget, number): if number <= 0: return ValidationError( _("This number must be positive " "and greater than 0")) self.end_reductions_number.set_range(number, 9999)
def on_expire_date__validate(self, widget, value): if value < localtoday().date(): msg = _(u"The expire date must be set to today or a future date.") return ValidationError(msg)
def from_string(self, value, format='png'): try: return pixbuf_from_string(value, format) except GObject.GError as e: raise ValidationError(_("Could not load image: %s") % e)
def on_description__validate(self, entry, text): if not text: return ValidationError(_("Account description cannot be empty"))
def _positive_validator(self, value): if not value: return if value and value < 0: return ValidationError(_(u'The value must be positive.'))
def _on_bank_option__validate(self, entry, value, bank_info, option): try: bank_info.validate_option(option, value) except BoletoException as e: return ValidationError(str(e)) self.bank_model.set_option(option, value)
def on_ncm__validate(self, widget, value): if len(value) not in (0, 8): return ValidationError(_(u'NCM must have 8 digits.'))
def on_profile_name__validate(self, widget, value): if self.model.check_unique_value_exists(UserProfile.name, value, case_sensitive=False): return ValidationError('This profile already exists!')
def on_ex_tipi__validate(self, widget, value): if len(value) not in (0, 2, 3): return ValidationError(_(u'EX TIPI must have 2 or 3 digits.'))
def on_number__validate(self, widget, value): query = And(Racer.race == self.race, Racer.id != self._current_model.id, Racer.number == value) if self.store.find(Racer, query).any(): return ValidationError('Número já utilizado')
def on_genero__validate(self, widget, value): if len(value) not in (0, 2): return ValidationError(_(u'Gênero must have 2 digits.'))
def on_p_cofins__validate(self, widget, value): if not 0 <= value <= 100: return ValidationError( _('The COFINS aliquot must be between 0 and 100'))
def on_yield_quantity__validate(self, widget, value): if value <= 0: return ValidationError(_(u'The value must be positive.'))
def on_quantity__validate(self, widget, value): if value <= 0: return ValidationError( _(u'Lost value should be greater than zero.'))
def on_combo__validate(self, widget, data): if data != 'Tre': return ValidationError("bar")