Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
3980 Zobrazení

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

Avatar
Zrušit

Please add some code/examples of what you already have. This is way too broad/vague to give a good answer.

Autor Nejlepší odpověď

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'
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
pro 24
1256
1
říj 15
9483
1
srp 25
325
2
čvc 25
2782
3
čvc 25
582