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:
- सीआरएम
- e-Commerce
- लेखांकन
- इन्वेंटरी
- PoS
- Project
- MRP
This question has been flagged
2
Replies
3976
Views
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!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
दिस॰ 24
|
1254 | ||
|
1
अक्तू॰ 15
|
9480 | ||
|
1
अग॰ 25
|
320 | ||
|
2
जुल॰ 25
|
2774 | ||
|
3
जुल॰ 25
|
579 |
Please add some code/examples of what you already have. This is way too broad/vague to give a good answer.