(first of all sorry for my bad english, i hope you can understand me)
Well i have to add a Custom ID to my objects of one of my models, this custom id is going to have a letter P or L if the related object have one or other attribute.
Specifically if the employee has the "Planta Permantente" or "Planta Contratada" attribute the custom ID will start with P and if you have the "Locacion de servicio" attribute will start with L. But both need to have correlative numbers. if i have P1 when i add a new certificate for a employee with "locacion de servicio" the custom id have to be "L1" and the next with P "P2"
how can i do this??
This is part of my employee model
CONTRACT_TYPES = (
(1, ("Planta Permanente")),
(2, ("Planta Contratada")),
(3, ("Locación de servicio")),
)
class Employee(models.Model):
cuil = models.CharField(
unique=True,
max_length=11,
verbose_name=_('CUIL'),
)
name = models.CharField(
max_length=50,
verbose_name=_('first name'),
)
middle_name = models.CharField(
blank=True,
max_length=50,
verbose_name=_('middle name'),
)
last_name = models.CharField(
max_length=100,
verbose_name=_('last name'),
)
have_children = models.BooleanField(
default=False)
contract = models.IntegerField(
choices=CONTRACT_TYPES,
verbose_name=_('contract'),
)
And this is part of my Certificate model
class Certificate(models.Model):
employee = models.ForeignKey(
Employee,
verbose_name=_('employee'),
)
place = models.IntegerField(
choices=ACCIDENT_PLACE,
default=1,
verbose_name=_('place')
)
detail = models.CharField(
max_length=255,
verbose_name=_('detail'),
)
clinic = models.ForeignKey(
Clinic,
verbose_name=_('clinic'),
)
Well thats what i need to do, if the employee have the contract type 1 or 2 identify with P1 P2 P3...P100...Pn and if is 3 the same but with L letter.
Any idea?
(Thanks very much)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…