I have a field containing date in days i would wish to set a condition whereby if number of days is past one another field is updated by a value of past sla and if less than one it is filled with within sla.which api should i use in my function and also possible sample practical explanation
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
2
Antwoorden
3981
Weergaven
Thanks Yenthe for your response here is my created fields
check_in_date = fields.Datetime(string="DateTime Opened", required=False,)
check_out_date = fields.Datetime(string="DateTime Closed", required=False,)
time_diff = fields.Float(string="Time Difference", required=False )
sla_state = fields.Selection(string="SLA", selection=[('past_sla', 'Past SLA'), ('within_sla', 'Within SLA'), ], required=False, )
state = fields.Selection([
here is my function for calculating date difference
@api.onchange('check_in_date', 'check_out_date','time_diff')
def calculate_date(self):
if self.check_in_date and self.check_out_date:
print "++++++++++++++++++++++++++++++++++++++++++++++++++"
print "++++++++++++++++++++++++++++++++++++++++++++++++++"
t1 = datetime.strptime(str(self.check_in_date), '%Y-%m-%d %H:%M:%S')
t2 = datetime.strptime(str(self.check_out_date), '%Y-%m-%d %H:%M:%S')
t3 = t2 - t1
self.time_diff = str(t3.days)
print "++++++++++++++++++++++++++++++++++++++++++++++++++"
print "++++++++++++++++++++++++++++++++++++++++++++++++++"
and here is my function for outputing the sla but its not giving me the result
@api.onchange('time_diff')
def get_time_diff(self):
if self.time_diff >= 1:
self.sla_state == 'Past SLA'
else:
self.sla_state == 'Within SLA'
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
dec. 24
|
1256 | ||
|
1
okt. 15
|
9483 | ||
|
1
aug. 25
|
326 | ||
|
2
jul. 25
|
2782 | ||
|
3
jul. 25
|
582 |
Please add some code/examples of what you already have. This is way too broad/vague to give a good answer.