<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Commission tab on hr.job (relocated verbatim from the merged
         partner_commission_management module). -->
    <record id="view_hr_job_form_inherit_commission" model="ir.ui.view">
        <field name="name">hr.job.form.inherit.affiliate.commission</field>
        <field name="model">hr.job</field>
        <field name="priority">100</field>
        <field name="inherit_id" ref="hr.view_hr_job_form"/>
        <field name="arch" type="xml">
            <xpath expr="//page[@name='recruitment_page']" position="after">
                <page name="job_partner_commissions" string="Affiliate Commissions">
                    <group>
                        <group>
                            <field name="base_amount"/>
                            <field name="currency_id" invisible="1"/>
                            <field name="x_is_paid" widget="boolean_toggle"/>
                        </group>
                        <group>
                            <field name="tracker_factor"/>
                        </group>
                    </group>
                    <div class="alert alert-info" role="alert"
                         invisible="x_is_paid or not base_amount">
                        Tick <strong>Payment Confirmed</strong> when the recruiter's
                        package payment is received. This creates the affiliate
                        commission as <em>Pending</em>. It will flip to
                        <em>Completed</em> automatically when the job is published.
                    </div>
                    <field name="partner_commission_ids"
                           context="{'default_transaction_type': 'commission'}">
                        <list editable="top" limit="15">
                            <field name="partner_id"/>
                            <field name="commission_percentage"/>
                            <field name="create_date" optional="hide"/>
                            <field name="commission_amount"/>
                            <field name="state" widget="badge"
                                   string="Status"
                                   decoration-success="state == 'completed'"
                                   decoration-info="state == 'pending'"
                                   decoration-muted="state == 'canceled'"/>
                            <field name="referrer_source" optional="hide"/>
                            <field name="bill_invoice_id" optional="show"/>
                            <field name="is_paid" optional="hide"/>
                            <field name="currency_id" column_invisible="True"/>
                        </list>
                    </field>
                    <group class="oe_subtotal_footer" colspan="2"
                           name="commission_total">
                        <div class="oe_inline o_td_label">
                            <label for="amount_total"/>
                        </div>
                        <field name="amount_total" nolabel="1"
                               class="oe_subtotal_footer_separator"/>
                    </group>
                </page>
            </xpath>
        </field>
    </record>
</odoo>
