This question has been flagged
1 Reply
2199 Views

I have the following fields:

“rec” this field is the automatic system date

“toma” It is a date that is entered“edad” is an integer which is entered

“falla” It is a date that should be automatically loaded fulfilling the following condition:

“falla” = if “falla” es < “rec” so “falla”= “rec” if not “falla”= “toma” + “edad”

Avatar
Discard

“toma” + “edad”

you are trying to add and integer to a date. Do you want to add the years to the date?

Best Answer

You can use compute field for 'rec' and 'falla'  and use datetime to get current date.

Write like this 

import datetime
@api.one
def _get_current_date(self):
     self.rec = datetime.datetime.now()

rec = fields.Datetime(compute='_get_current_date')
toma = fields.Datetime()
edad = fields.Datetime()

@api.one
def _get_falla(self):
    # Assign to falla using your condition
    pass

falla = fields.Datetime(compute='_get_falla')
Note, I did n't test the above code  
Avatar
Discard