'Find the earliest start_date of the latests sessions'

def _default_start_date(self):

    config_ids = self.env['pos.config'].search([]).ids
    self.env.cr.execute("\n                                                SELECT\n                                                max(start_at)    as    start,\n                                                config_id\n                                                FROM    pos_session\n                                                WHERE    config_id    =    ANY(%s)\n                                                AND    start_at    >    (NOW()    -    INTERVAL    '2    DAYS')\n                                                GROUP    BY    config_id\n                                ", (config_ids,))
    latest_start_dates = [res['start'] for res in self.env.cr.dictfetchall()]
    return ((latest_start_dates and min(latest_start_dates)) or fields.Datetime.now())
