from datetime import timedelta
# custom save model
def save(self, *args, **kwargs):
# figure out warranty end date
if self.warranty_period_type == 'm':
self.warranty_end_date = self.purchase_date + timedelta(days=self.warranty_period_number*31)
else:
self.warranty_end_date = self.purchase_date + timedelta(days=self.warranty_period_number*365.2425)
super(Purchase, self).save(*args, **kwargs)