Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
568 Ansichten

Hello,

I'm working on a model in which there should be a progress bar depicting a kind of countdown to a certain date.

At the moment the code looks like this:


remainingOperationTime = fields.Float(string='Remaining operation time',                                          compute='_calculate_remaining_operation_time', store=True) 


@ api.depends('nextRecertification')    

def _calculate_remaining_operation_time(self):        

​rot = 0.0        

​for asset in self:            

​if not asset.nextRecertification:                

​rot = 0.0            

​else:                

​delta = asset.nextRecertification - date.today()                

​rot = (delta.days / 365) * 100            

​asset.remainingOperationTime = float(rot)


(of course this isn't all of it...)


When creating an entry the remaining time is calculated and the progress bar shows but it isn't updated when time passes. How can I get it to update every day?

Working in Odoo14.


Thanks!

Avatar
Verwerfen