Hello,
I've model_a.py like this:
name = fields.Many2one('hr.employee', 'Employee Name')
date_work = fields.Date('Date')
value1 = fields.Float('Value 1')
value2 = fields.Float('Value 2')
In the tree view of model_a.py. I selected Employee name and put values for date_work, value1 and value2 like this:
Employee Name Date Value1 Value2
Anita 11/13/2021 1.0 2.0
Randall 11/13/2021 3.0 4.0
Randall 11/14/2021 5.0 6.0
Marc 11/13/2021 1.0 2.0
Randall 11/15/2021 7.0 8.0
...
So, I want to determine/get the MIN/MAX of field: 'value1' of 'Randall' on only 2 dates: 11/13/2021 and 11/14/2021
I'd tried to use compute field to determine the MIN/MAX of field 'value1' like this:
min_value1 = fields.Float('Value 1', compute='_get_min_value1')
@api.depends('value1')
def _get_min_value1(self):
for rec in self:
min_value1_val = min(self.filtered(lambda x: x.name == rec.name and x.date_work == rec.date_work and x.date_work == rec.date_work + timedelta(days=1).mapped('value1'))
rec.min_value1 = min_value1_val
...
But I got the error with this way.
So how to determine/get the MIN/MAX in the list of field based on 2 specific different dates of the same user name?
Please help!
Thank you!