<?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 model="ir.ui.view" id="golem_member_form_inherit_golem_membership">
      <field name="name">GOLEM Member form adaptations</field>
      <field name="model">golem.member</field>
      <field name="inherit_id" ref="golem_member.golem_member_form" />
      <field name="arch" type="xml">
        <page name="other_page" position="before">
          <page string="Membership">
            <group>
              <group>
                <field name="free_member"/>
                <label for="membership_state"/>
                <div>
                  <field name="partner_id" invisible="True" required="False" />
                  <field name="membership_state"/>
                  <button name="%(golem_membership_invoice_action)d"
                    type="action" string="Buy Membership"
                    attrs="{'invisible':[('free_member','=',True)]}"
                    context="{'default_partner_id': partner_id}"
                    class="oe_link"/>
                </div>
              </group>
              <group>
                <field name="membership_start"
                  attrs="{'invisible':[('membership_start','=',False)]}"/>
                <field name="membership_stop"
                  attrs="{'invisible':[('membership_stop','=',False)]}"/>
                <field name="membership_cancel"
                  attrs="{'invisible':[('membership_cancel','=',False)]}"/>
              </group>
            </group>
            <field name="member_lines" nolabel="1" colspan="4" readonly="1">
              <tree string="Memberships">
                <field name="date"/>
                <field name="membership_id"/>
                <field name="member_price"/>
                <field name="account_invoice_id"/>
                <field name="state"/>
              </tree>
              <form string="Memberships">
                <group>
                  <field name="date"/>
                  <field name="member_price"/>
                  <field name="membership_id"/>
                  <field name="account_invoice_id"
                    context="{'form_view_ref': 'account.invoice_form'}"/>
                  <field name="state" colspan="4"/>
                </group>
              </form>
            </field>
          </page>
        </page>
      </field>
    </record>
<!-- Searches -->
    <record model="ir.ui.view" id="golem_member_search_inherit_golem_membership">
      <field name="name">GOLEM Member form adaptations</field>
      <field name="model">golem.member</field>
      <field name="inherit_id" ref="golem_member.golem_member_search" />
      <field name="arch" type="xml">
        <filter name="season_default" position="after">
          <separator />
          <filter name="has_contributed" string="Has contributed"
            domain="[('membership_state','in',['invoiced', 'paid'])]" />
          <filter name="is_free_member" string="Is Free Member"
            domain="[('free_member', '=', True)]" />
          </filter>
      </field>
    </record>

  </data>
</odoo>