<?xml version="1.0" encoding="utf-8"?>

<!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->

<odoo>
  <data>

    <!-- Forms -->
    <record id="golem_season_view_form" model="ir.ui.view">
      <field name="name">GOLEM Season Form</field>
      <field name="model">golem.season</field>
      <field name="arch" type="xml">
        <form>
          <sheet>
            <div class="oe_right">
              <button name="do_default_season" type="object"
                string="Make this season as default" class="oe_highlight"
                help="Default season for views ?"
                attrs="{'invisible': [('is_default', '=', True)]}" />
            </div>
            <group string="Season">
              <field name="is_default" invisible="True" />
              <field name="membership_id" options="{'no_create': true}"/>
              <field name="name" attrs="{'required': True}" />
              <field name="date_start"
                attrs="{'required': [('date_end', '!=', False)]}" />
              <field name="date_end"
                attrs="{'required': [('date_start', '!=', False)]}" />
            </group>
          </sheet>
        </form>
      </field>
    </record>

    <!-- Trees -->
    <record id="golem_season_view_tree" model="ir.ui.view">
      <field name="name">GOLEM Seasons</field>
      <field name="model">golem.season</field>
      <field name="arch" type="xml">
        <tree>
          <field name="name" />
          <field name="is_default" />
          <field name="date_start" />
          <field name="date_end" />
        </tree>
      </field>
    </record>

    <!-- Search -->
    <record id="golem_season_search" model="ir.ui.view">
      <field name="name">GOLEM Seasons Filters</field>
      <field name="model">golem.season</field>
      <field name="arch" type="xml">
        <search>
          <field name="name" />
          <filter name="default_season" string="Default season"
           domain="[('is_default', '=', True)]" />
        </search>
      </field>
    </record>

    <!-- Actions -->
    <act_window id="golem_season_action" name="GOLEM Seasons"
      res_model="golem.season" view_mode="tree,form" />

    <!-- Menus -->
    <menuitem id="golem_season_menu" name="GOLEM Seasons" sequence="100"
      groups="golem_base.group_golem_manager"
      web_icon="golem_season,static/description/icon.png" />
    <menuitem id="golem_season_menu_list" name="Seasons" sequence="1"
      parent="golem_season_menu" action="golem_season_action"
      groups="golem_base.group_golem_manager" />

  </data>
</odoo>