I'm declaring a function (data_prox_prog) to calculate a future date and store in the model, but it's not happening as expected. Here is the code:
class ProgressaoDocente(models.Model):
servidor = models.ForeignKey(Servidor, on_delete=models.PROTECT)
tipo_progressao = models.CharField(choices=const.TIPO_PROGRESSAO_DOC, max_length=1)
classe = models.CharField(choices=const.CLASSE_DOCENTE, max_length=1)
nivel = models.CharField(choices=const.NIVEL_DOCENTE, max_length=1)
data_progressao = models.DateField()
portaria = models.OneToOneField(Portaria, on_delete=models.CASCADE)
data_prox_progressao = models.DateField(blank=True, null=True)
class Meta:
verbose_name_plural = 'Progressão Docente'
def data_prox_prog(self):
self.data_prox_prog = (self.data_progressao + timedelta(year=2))
self.save()
def __str__(self):
return "{} {}, {}/{}".format(self.servidor, self.tipo_progressao, self.classe, self.nivel)