<odoo>
  <data>

    <record id="runbot_error_log_form_view" model="ir.ui.view">
      <field name="name">Runbot Error Log form view</field>
      <field name="model">runbot.error.log</field>
      <field name="arch" type="xml">
        <form string="Build Error">
          <header>
          </header>
          <sheet>
              <div class="oe_button_box" name="button_box" groups="base.group_user">
              </div>
              <div class="oe_title">
                  <h1><field name="build_id"/></h1>
                  <field name="build_url" widget="url"/>
                  &amp;nbsp;<field name="log_create_date"/>
              </div>
              <group>
                  <group>
                    <field name="log_type"/>
                  </group>
                  <group>
                    <field name="name"/>
                    <field name="func"/>
                    <field name="path"/>
                  </group>
              </group>
              <notebook>
                  <page string="Log message" name="log_message">
                    <group>
                      <field name="message"/>
                    </group>
                  </page>
              </notebook>
          </sheet>
        </form>
      </field>
    </record>

    <record id="runbot_error_log_tree_view" model="ir.ui.view">
      <field name="name">Runbot Error Log list view</field>
      <field name="model">runbot.error.log</field>
      <field name="arch" type="xml">
        <list string="Build Errors">
          <button name="action_goto_build" type="object" icon="fa-external-link" title="View build"/>
          <field name="build_id"/>
          <field name="bundle_ids" widget="many2many_tags"/>
          <field name="log_create_date"/>
          <field name="name"/>
          <field name="func"/>
          <field name="path"/>
          <field name="summary"/>
          <field name="log_type"/>
        </list>
      </field>
    </record>

    <record id="runbot_logs_search_view" model="ir.ui.view">
      <field name="name">runbot.error.log.filter</field>
      <field name="model">runbot.error.log</field>
      <field name="arch" type="xml">
        <search string="Search master">
          <field name="message"/>
          <field name="name" string="Module"/>
          <field name="func"/>
          <field name="build_id"/>
          <filter string="Failed builds" name="failed_builds" domain="[('global_state', '=', 'done'), ('global_result', '=', 'ko')]"/>
          <separator/>
          <filter string="Master bundle" name="master_bundle" domain="[('bundle_ids.name', '=', 'master')]"/>
          <filter string="Sticky bundles" name="sticky_bundles" domain="[('sticky', '=', True)]"/>
          <separator/>
          <!-- <filter name="filter_log_create_date" date="log_create_date" string="Log Date" default_period="last_7_days"/> -->
          <filter string="Last 7 Days" name="log_date" domain="[
                        ('log_create_date', '>=', (datetime.datetime.combine(context_today() + relativedelta(days=-7), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S')),
                        ('log_create_date', '&lt;', (datetime.datetime.combine(context_today(), datetime.time(0,0,0)).to_utc()).strftime('%Y-%m-%d %H:%M:%S'))]"/>
        </search>
      </field>
    </record>

    <record id="open_view_error_log_tree" model="ir.actions.act_window">
        <field name="name">Error Logs</field>
        <field name="res_model">runbot.error.log</field>
        <field name="view_mode">list,form</field>
        <!-- <field name="context">{'search_default_sticky_bundles': True, 'search_default_failed_builds': True, 'time_ranges': {'field': 'log_create_date', 'range': 'last_7_days'},}</field> -->
        <field name="context">{'search_default_sticky_bundles': True, 'search_default_failed_builds': True, 'search_default_log_date': True}</field>
    </record>

  </data>
</odoo>
