<?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/>.
-->

<openerp>
  <data>
    <!-- Forms -->
    <record model="ir.ui.view" id="membership_add">
      <field name="name">Add membership button</field>
      <field name="model">golem.member</field>
      <field name="inherit_id" ref="golem_member.view_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="%(action_membership_invoice_view)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">
                <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"/>
              </form>
            </field>
          </page>
        </page>
      </field>
    </record>

  </data>
</openerp>