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
- Financeiro
- Inventário
- PoS
- Project
- MRP
Esta pergunta foi sinalizada
2
Respostas
3978
Visualizações
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'
Está gostando da discussão? Não fique apenas lendo, participe!
Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!
Inscreva-sePublicações relacionadas | Respostas | Visualizações | Atividade | |
---|---|---|---|---|
|
0
dez. 24
|
1255 | ||
New api search domain id and condition?
Resolvido
|
|
1
out. 15
|
9483 | |
|
1
ago. 25
|
323 | ||
|
2
jul. 25
|
2780 | ||
API xmlrpc - upload pdf bills to account
Resolvido
|
|
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.