<?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_invoicing_view_form" model="ir.ui.view">
      <field name="name">GOLEM Activity Registration Invoicing Form</field>
      <field name="model">golem.activity.registration.invoicing</field>
      <field name="arch" type="xml">
        <form string="Registration invoicing">
          <field name="state" invisible="1" />
          <p states="init" class="oe_grey">
            Please confirm activity prices and choose a payment schedule if needed.
          </p>
          <group states="init">
            <group name="lines" colspan="2">
              <field name="season_id" readonly="1" />
              <field name="member_id" readonly="1" />
              <field name="line_ids" string="Activities and Prices">
                <tree delete="false" create="false" edit="true" editable="bottom">
                  <field name="activity_id" readonly="1" />
                  <field name="currency_id" invisible="1" />
                  <field name="price" sum="Total" />
                </tree>
              </field>
            </group>
            <group name="payment" colspan="2">
              <field name="schedule_id" context="{'default_season_id': season_id}" />
              <field name="journal_id" string="Payment method"
                options="{'no_create': True}"
                attrs="{'invisible': [('schedule_id', '=', False)],
                'required': [('schedule_id', '!=', False)]}" />
            </group>
          </group>
          <p states="init">If the service user wants to pay with several payment methods, please validate with the main one, go to the payments and change journal on those needed.</p>
          <p states="final">
            Congratulations, activities had been confirmed and invoiced.
          </p>
          <group states="final">
            <group>
              <field name="invoice_id" readonly="1" />
              <field name="payment_ids" readonly="1" />
            </group>
          </group>
          <footer>
            <button name="validate" string="Validate" type="object"
              states="init" class="oe_highlight" />
            <button name="go_invoice" string="Display invoice" type="object"
              states="final" class="oe_highlight" />
            <button name="go_payments" string="Display payments" type="object"
              states="final" />
            <button string="Close" class="oe_link" special="cancel" />
          </footer>
        </form>
      </field>
    </record>

  </data>
</odoo>