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:
- Müşteri İlişkileri Yönetimi
- e-Commerce
- Muhasebe
- Envanter
- PoS
- Project
- MRP
Bu soru işaretlendi
2
Cevaplar
3985
Görünümler
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'
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Üye Olİlgili Gönderiler | Cevaplar | Görünümler | Aktivite | |
---|---|---|---|---|
|
0
Ara 24
|
1259 | ||
|
1
Eki 15
|
9483 | ||
|
1
Ağu 25
|
342 | ||
|
2
Tem 25
|
2792 | ||
|
3
Tem 25
|
605 |
Please add some code/examples of what you already have. This is way too broad/vague to give a good answer.