Hello Team,
I have calculated the date difference here is my .py code
@api.onchange('from_date', 'to_date')
def _calc_days(self):
if self.to_date and self.from_date:
self.duration = datetime.strptime(str(self.to_date), "%Y-%m-%d %H:%M:%S") - datetime.strptime(
str(self.from_date), "%Y-%m-%d %H:%M:%S")
from_date = fields.Datetime(string='Start Date', required=True)
to_date = fields.Datetime(string='End Date', required=True)
duration = fields.Char(
'Number of Days',
readonly=True,
compute=_calc_days
)
I Want to compute price computation the other field is in float,
Computational code is heretotal_per_diem_cost = fields.Float(
string='Total Per Diem Cost',
required=True,
compute="total_diem_compute",
)
@api.depends('staff_per_diem', 'duration')Then the challenge comes, how can I change the duration field which is in char form to float?? kindly assist please,
def total_diem_compute(self):
for rec in self:
rec.total_per_diem_cost = rec.staff_per_diem * rec.duration
Regards
Loomoni