<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017-2018 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>

    <!-- Form -->
    <record id="golem_activity_registration_form" model="ir.ui.view">
      <field name="name">Activity registration form</field>
      <field name="model">golem.activity.registration</field>
      <field name="arch" type="xml">
        <form>
          <header></header>
          <sheet>
            <group>
              <group name="subscription" string="Subscription">
                <field name="activity_id" />
                <field name="season_id" />
                <field name="member_id" />
              </group>
            </group>
          </sheet>
        </form>
      </field>
    </record>


    <!-- Tree -->
    <record id="golem_activity_registration_tree" model="ir.ui.view">
      <field name="name">Activity registration list</field>
      <field name="model">golem.activity.registration</field>
      <field name="arch" type="xml">
        <tree create="true" edit="true" delete="false" editable="top">
          <field name="season_id" readonly="1"
            invisible="not context.get('season_show', 1)" />
          <field name="member_id" domain="[('is_default', '=', True)]"
            invisible="not context.get('member_show', 1)" />
          <field name="activity_id" domain="[('is_default', '=', True)]"
            invisible="not context.get('activity_show', 1)" />
          <field name="activity_price" string="Base price" sum="Total"
            invisible="not context.get('activity_show', 1)" />
        </tree>
      </field>
    </record>

    <!-- Search -->
    <record id="golem_activity_registration_search" model="ir.ui.view">
      <field name="name">GOLEM Activity Registration searches</field>
      <field name="model">golem.activity.registration</field>
      <field name="arch" type="xml">
        <search>
          <field name="season_id" />
          <field name="member_id" />
          <field name="activity_id" />
          <filter name="season_default" string="Default season"
           domain="[('is_default', '=', True)]" />
         <filter name="group_season" string="By season"
           context="{'group_by': 'season_id'}"/>
        </search>
      </field>
    </record>

    <!-- Action -->
    <record id="golem_activity_registration_action" model="ir.actions.act_window">
      <field name="name">GOLEM Activity Registration List</field>
      <field name="res_model">golem.activity.registration</field>
      <field name="view_mode">tree,form</field>
    </record>

    <!-- Menu -->
    <menuitem id="golem_activity_registration_menu" name="Activity registrations"
      parent="golem_activity.golem_activity_menu"
      action="golem_activity_registration_action"
      groups="golem_base.group_golem_user"
      sequence="20" />

  </data>
</odoo>