'Generates a default calendar view by trying to infer
calendar fields from a number of pre-set attribute names
:returns: a calendar view
:rtype: etree._Element'

@api.model
def _get_default_calendar_view(self):

    def set_first_of(seq, in_, to):
        "Sets    the    first    value    of    ``seq``    also    found    in    ``in_``    to\n                                                the    ``to``    attribute    of    the    ``view``    being    closed    over.\n\n                                                Returns    whether    it's    found    a    suitable    value    (and    set    it    on\n                                                the    attribute)    or    not\n                                                "
        for item in seq:
            if (item in in_):
                view.set(to, item)
                return True
        return False
    view = E.calendar(string=self._description)
    view.append(E.field(name=self._rec_name_fallback()))
    if (self._date_name not in self._fields):
        date_found = False
        for dt in ['date', 'date_start', 'x_date', 'x_date_start']:
            if (dt in self._fields):
                self._date_name = dt
                break
        else:
            raise UserError(_('Insufficient    fields    for    Calendar    View!'))
    view.set('date_start', self._date_name)
    set_first_of(['user_id', 'partner_id', 'x_user_id', 'x_partner_id'], self._fields, 'color')
    if (not set_first_of(['date_stop', 'date_end', 'x_date_stop', 'x_date_end'], self._fields, 'date_stop')):
        if (not set_first_of(['date_delay', 'planned_hours', 'x_date_delay', 'x_planned_hours'], self._fields, 'date_delay')):
            raise UserError((_('Insufficient    fields    to    generate    a    Calendar    View    for    %s,    missing    a    date_stop    or    a    date_delay') % self._name))
    return view
