<?xml version="1.0"?>
<odoo>
    <record id="view_pos_elavon_configuration_form" model="ir.ui.view" >
        <field name="name">Elavon Configurations</field>
        <field name="model">pos_elavon.configuration</field>
        <field name="arch" type="xml">
            <form string="Card Reader">
                <sheet>
                    <div class="oe_title">
                       <label for="name" class="oe_edit_only"/>
                       <h1><field name="name"/></h1>
                    </div>
                    <div>
                        <p>
                            <i>Elavon Configurations</i> define what Elavon account will be used when
                            processing credit card transactions in the Point Of Sale. Setting up a Elavon
                            configuration will enable you to allow payments with various credit cards
                            (eg. Visa, MasterCard, Discovery, American Express, ...). After setting up this
                            configuration you should associate it with a Point Of Sale payment method.
                        </p><p>
                            We currently support standard card reader devices. It can be connected
                            directly to the Point Of Sale device or it can be connected to the POSBox.
                        </p><p>
                            Using the Elavon integration in the Point Of Sale is easy: just press the
                            associated payment method. After that the amount can be adjusted (eg. for cashback)
                            just like on any other payment line. Whenever the payment line is set up, a card
                            can be swiped through the card reader device.
                        </p><p>
                            For quickly handling orders: just swiping a credit card when on the payment screen
                            (without having pressed anything else) will charge the full amount of the order to
                            the card.
                        </p><p>
                            Note that you will need to setup a 'PIN' number on POS Teams.
                        </p>
                    </div>
                    <group col="2">
                        <field name="merchant_id"/>
                        <field name="merchant_user_id"/>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

    <record id="view_pos_elavon_configuration_tree" model="ir.ui.view">
        <field name="name">Elavon Configurations</field>
        <field name="model">pos_elavon.configuration</field>
        <field name="arch" type="xml">
            <tree string="Card Reader">
                <field name="name"/>
                <field name="merchant_id"/>
            </tree>
        </field>
    </record>

    <record id="action_configuration_form" model="ir.actions.act_window">
        <field name="name">Elavon Configurations</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">pos_elavon.configuration</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,kanban,form</field>
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to configure your card reader.
          </p>
        </field>
    </record>

    <record id="view_account_journal_pos_user_form" model="ir.ui.view">
        <field name="name">POS Journal</field>
        <field name="model">account.journal</field>
        <field name="inherit_id" ref="point_of_sale.view_account_journal_pos_user_form"></field>
        <field name="arch" type="xml">
            <xpath expr="//group[@name='amount_authorized']" position="after">
                <group attrs="{'invisible': [('type', '!=', 'bank')]}">
                    <field name="pos_elavon_config_id"/>
                </group>
            </xpath>
        </field>
    </record>
    <record id="view_account_bank_journal_form_inherited_pos_elavon" model="ir.ui.view">
        <field name="name">account.bank.journal.form.inherited.pos.elavon</field>
        <field name="model">account.journal</field>
        <field name="inherit_id" ref="point_of_sale.view_account_bank_journal_form_inherited_pos"></field>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='journal_user']" position="after">
                <field name="pos_elavon_config_id" attrs="{'invisible': [('journal_user', '=', False)]}"/>
            </xpath>
        </field>
    </record>

    <record id="crm_team_view_form_inherit_pos_sale_elavon" model="ir.ui.view">
        <field name="name">crm.team.form.pos.elavon</field>
        <field name="model">crm.team</field>
        <field name="inherit_id" ref="pos_sale.crm_team_view_form_inherit_pos_sale"></field>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='company_id']" position="after">
                <field name="pos_elavon_merchant_pin"/>
            </xpath>
        </field>
    </record>

    <record id="view_pos_order" model="ir.ui.view">
      <field name="name">POS orders</field>
      <field name="model">pos.order</field>
      <field name="inherit_id" ref="point_of_sale.view_pos_pos_form"/>
      <field name="arch" type="xml">
        <xpath expr="//field[@name='amount']" position="before">
          <field name="elavon_card_number"/>
          <field name="elavon_txn_id"/>
        </xpath>
      </field>
    </record>

    <menuitem parent="point_of_sale.menu_point_config_product" action="pos_elavon.action_configuration_form" id="menu_pos_pos_elavon_config" groups="base.group_no_one" sequence="35"/>

</odoo>
