<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 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_activity_form" model="ir.ui.view">
      <field name="name">GOLEM Activity Form</field>
      <field name="model">golem.activity</field>
      <field name="arch" type="xml">
        <form>
          <header />
          <sheet>
            <div class="oe_clear oe_right oe_button_box"
              style="width: 300px;"
              name="buttons"></div>
            <div class="oe_left" style="width: 500px;">
              <field name="image" widget="image" class="oe_avatar oe_left"/>
              <div class="oe_title" style="width: 390px;">
                <label class="oe_edit_only" for="name" string="Activity Name"/>
                <h1><field name="name" required="True" class="oe_inline"/></h1>
              </div>
            </div>
            <group>
              <group>
                <field name="season_id" required="True" />
                <field name="animator_id" />
                <field name="type_id" required="True" />
              </group>
              <group>
                <field name="categ_id" required="True" />
                <field name="default_code" />
                <field name="list_price" />
              </group>
            </group>
            <notebook>
              <page name="session" string="Session">
                <group>
                  <group name="dates">
                    <field name="is_recurrent" />
                    <field name="weekday"
                      attrs="{'invisible': [('is_recurrent', '=', False)]}" />
                    <field name="hour_start" widget="float_time"
                      attrs="{'invisible': [('is_recurrent', '=', False)]}" />
                    <field name="hour_stop" widget="float_time"
                      attrs="{'invisible': [('is_recurrent', '=', False)]}" />
                    <field name="date_start"
                      attrs="{'invisible': [('is_recurrent', '=', True)]}" />
                    <field name="date_stop"
                      attrs="{'invisible': [('is_recurrent', '=', True)]}" />
                  </group>
                  <group name="places">
                  </group>
                </group>
              </page>
              <page string="Invoicing" name="invoicing"
                groups="account.group_account_invoice">
                <group name="properties">
                  <field name="property_account_income_id"
                    domain="[('internal_type','=','other'),('deprecated','=',False)]"
                    groups="account.group_account_user"/>
                  <field name="taxes_id" widget="many2many_tags"/>
                  <field name="property_account_expense_id"
                    domain="[('internal_type','=','other'),('deprecated','=',False)]"
                    groups="account.group_account_user"/>
                  <field name="supplier_taxes_id" widget="many2many_tags"/>
                </group>
              </page>
              <page name="activity_others" string="Others">
                <group>
                  <field name="description"
                    placeholder="describe the activity characteristics..." />
                  <field name="active" />
                </group>
              </page>
            </notebook>
          </sheet>
          <div class="oe_chatter">
            <field name="message_follower_ids" widget="mail_followers" />
            <field name="message_ids" widget="mail_thread" />
          </div>
        </form>
      </field>
    </record>

    <!-- Trees -->
    <record model="ir.ui.view" id="golem_activity_tree">
      <field name="name">GOLEM Activity Tree/List</field>
      <field name="model">golem.activity</field>
      <field name="arch" type="xml">
        <tree>
          <field name="is_recurrent" invisible="True" />
          <field name="season_id" />
          <field name="type_id" />
          <field name="full_name" />
          <field name="animator_id" />
          <field name="weekday" string="Day"
              attrs="{'invisible': [('is_recurrent', '=', False)]}" />
          <field name="date_start" string="Date"
              attrs="{'invisible': [('is_recurrent', '=', True)]}" />
          <field name="list_price" sum="True" />
        </tree>
      </field>
  </record>
  <record model="ir.ui.view" id="golem_activity_type_tree">
    <field name="name">GOLEM Activity Type Tree/List</field>
    <field name="model">golem.activity.type</field>
    <field name="arch" type="xml">
      <tree editable="top">
        <field name="name" />
        <field name="is_recurrent" />
      </tree>
    </field>
  </record>

    <!-- Calendars -->
    <record id="golem_activity_calendar" model="ir.ui.view">
      <field name="name">Activity calendar view</field>
      <field name="model">golem.activity</field>
      <field name="arch" type="xml">
        <calendar date_start="date_start" date_stop="date_stop"
          color="categ_id" display="[name]">
          <field name="name" />
        </calendar>
      </field>
    </record>

    <!-- Searches -->
    <record id="golem_activity_search" model="ir.ui.view">
      <field name="name">GOLEM Activity Filters</field>
      <field name="model">golem.activity</field>
      <field name="arch" type="xml">
        <search>
          <field name="full_name" />
          <field name="animator_id" />
          <field name="type_id" />
          <field name="categ_id" />
          <field name="season_id" />
          <filter name="season_default" string="Default season"
           domain="[('is_current', '=', True)]" />
          <group string="Group By">
            <filter name="group_type_id" string="By type"
              context="{'group_by': 'type_id'}" />
            <filter name="group_category" string="By category"
              context="{'group_by': 'categ_id'}"/>
            <filter name="group_weekday" string="By weekday"
              context="{'group_by': 'weekday'}" />
            <filter name="group_animator" string="By animator"
              context="{'group_by': 'animator_id'}" />
          </group>
        </search>
      </field>
    </record>

    <!-- Actions -->
    <act_window id="golem_activity_action" name="GOLEM Activities"
      res_model="golem.activity" view_mode="tree,form,calendar"
      context="{'search_default_season_default': True}" />
    <act_window id="golem_activity_type_action" name="GOLEM Activity Types"
      res_model="golem.activity.type" view_mode="tree" />
    <record id="product_category_action" model="ir.actions.act_window">
      <field name="name">Activities Categories</field>
      <field name="res_model">product.category</field>
      <field name="view_type">form</field>
      <field name="view_id" ref="product.product_category_list_view" />
    </record>

    <!-- Menus -->
    <menuitem id="golem_activity_menu" name="Activities" sequence="30"
      groups="golem_base.group_golem_user"
      web_icon="golem_activity,static/description/icon.png" />
    <menuitem id="golem_activity_menu_list" name="Activities"
      groups="golem_base.group_golem_user"
      parent="golem_activity_menu" sequence="1" action="golem_activity_action" />
    <menuitem id="golem_activity_menu_configuration" name="Configuration"
      parent="golem_activity_menu" sequence="90"
      groups="golem_base.group_golem_manager" />
    <menuitem id="golem_activity_type_menu_list" name="Activity Types"
      groups="golem_base.group_golem_manager"
      parent="golem_activity_menu_configuration" sequence="5"
      action="golem_activity_type_action" />
    <menuitem  id="product_category_menu" name="Categories"
      parent="golem_activity_menu_configuration" sequence="10"
      groups="golem_base.group_golem_manager"
      action="product_category_action" />

  </data>
</odoo>