my field
SCHEDULE_SELECTION = [
("no_schedule", "Без терміну"),
("overdue", "Протерміновано"),
("today", "Сьогодні"),
("this_week", "Цього тижня"),
("next_week", "Наступного тижня"),
("after_2_week", "Більше 2 тижнів"),
]
schedule_selection = fields.Selection(selection=SCHEDULE_SELECTION, string="Групування по терміну", compute='_compute_schedule_date')
def _compute_schedule_date(self):
for i in self:
...
if not i.schedule_date or i.done:
i.schedule_selection = "no_schedule"
elif i.is_overdue:
i.schedule_selection = "overdue"
else:
selection_difference = (i.schedule_date - now).days
if i.schedule_date.date() == now_date:
i.schedule_selection = "today"
elif selection_difference <= 7:
i.schedule_selection = "this_week"
elif selection_difference <= 14:
i.schedule_selection = "next_week"
else:
i.schedule_selection = "after_2_week"
and search:
<!-- this don`t work, i receive an error -->
<filter string='Термін' name='schedule_selection' domain="[]" context="{'group_by': 'schedule_selection'}"/>
as you can see, in this situation i can`t use "store=True", because this field depends by other fields(stored and computed) and current datetime.
on the Internet I found several posts where people say that for this you need to override the search() method, but I did not find specific examples.