hr_expense_account_split/views/hr_expense_views.xml

238 lines
14 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Expense Line Form View -->
<record id="hr_expense_view_form_inherit_receipt" model="ir.ui.view">
<field name="name">hr.expense.view.form.receipt</field>
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_form"/>
<field name="priority">1000</field>
<field name="arch" type="xml">
<!-- Remove all standard Submit Buttons -->
<xpath expr="(//header//button[@name='action_submit_expenses'])[1]" position="replace"/>
<xpath expr="(//header//button[@name='action_submit_expenses'])[1]" position="replace"/>
<!-- Remove all standard Attach Receipt widgets -->
<xpath expr="(//header//widget[@name='attach_document'])[1]" position="replace"/>
<xpath expr="(//header//widget[@name='attach_document'])[1]" position="replace"/>
<!-- Remove Split Expense to re-add with correct logic -->
<xpath expr="//header//button[@name='action_split_wizard']" position="replace"/>
<!-- Re-add ONLY one Create Report button as primary -->
<xpath expr="//header" position="inside">
<button name="action_submit_expenses"
string="Create Report"
type="object"
class="oe_highlight o_expense_submit"
invisible="sheet_id"
data-hotkey="v"/>
<widget name="attach_document"
string="Attach Receipt"
action="attach_document"
highlight="nb_attachment &lt; 1 and payment_mode == 'own_account'"
invisible="sheet_id"/>
</xpath>
<xpath expr="//div[hasclass('oe_title')]" position="before">
<div class="oe_button_box" name="button_box">
<button name="action_view_realizations"
type="object"
class="oe_stat_button"
icon="fa-file-text-o"
invisible="realization_count == 0">
<field name="realization_count" widget="statinfo" string="Realization"/>
</button>
<!-- Button to create new realization if none exists -->
<button name="action_create_realization"
string="Realization"
type="object"
class="oe_stat_button"
icon="fa-plus-square-o"
invisible="payment_mode != 'company_account' or state not in ['done', 'reported'] or realization_count != 0"/>
</div>
</xpath>
<xpath expr="//sheet" position="before">
<field name="sequence_name" invisible="1"/>
<div class="alert alert-danger mb-2" role="alert" invisible="not receipt_overdue">
This receipt is <strong>Overdue</strong>! Please submit the original receipt as soon as possible.
</div>
</xpath>
<xpath expr="//div[hasclass('oe_title')]" position="inside">
<h1>
<field name="sequence_name" readonly="1" invisible="not id"/>
</h1>
</xpath>
<xpath expr="//field[@name='account_id']" position="after">
<field name="realization_total_amount" invisible="payment_mode != 'company_account'"/>
<field name="realization_count" invisible="1"/>
<field name="receipt_due_date" widget="date" invisible="not receipt_due_date"/>
<field name="receipt_received" widget="boolean_toggle" invisible="not receipt_due_date"/>
<field name="receipt_overdue" invisible="1"/>
</xpath>
</field>
</record>
<!-- Expense Line Tree View -->
<record id="view_expenses_tree_inherit_receipt" model="ir.ui.view">
<field name="name">hr.expense.tree.receipt</field>
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.view_expenses_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="before">
<field name="sequence_name" optional="show"/>
</xpath>
<xpath expr="//field[@name='total_amount']" position="after">
<field name="realization_total_amount" optional="show" sum="Total Realization" invisible="payment_mode != 'company_account'"/>
</xpath>
<xpath expr="//field[@name='state']" position="after">
<field name="receipt_due_date" optional="show" widget="remaining_days" decoration-danger="receipt_overdue"/>
<field name="receipt_received" optional="show" widget="boolean_toggle"/>
<field name="receipt_overdue" column_invisible="True"/>
</xpath>
</field>
</record>
<!-- Expense Search View -->
<record id="hr_expense_view_search_inherit_receipt" model="ir.ui.view">
<field name="name">hr.expense.search.receipt</field>
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_search"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='no_report']" position="after">
<separator/>
<filter string="Overdue Receipts" name="filter_receipt_overdue" domain="[('receipt_overdue', '=', True), ('receipt_received', '=', False)]"/>
<filter string="Receipt Received" name="filter_receipt_received" domain="[('receipt_received', '=', True)]"/>
<filter string="Receipt Missing" name="filter_receipt_missing" domain="[('receipt_received', '=', False), ('receipt_due_date', '!=', False)]"/>
</xpath>
<xpath expr="//group" position="inside">
<filter string="Receipt Status" name="group_receipt_status" context="{'group_by': 'receipt_received'}"/>
<filter string="Receipt Due Date" name="group_receipt_due" context="{'group_by': 'receipt_due_date'}"/>
</xpath>
</field>
</record>
<!-- Report Action: Overdue Receipts -->
<record id="action_hr_expense_overdue_receipts" model="ir.actions.act_window">
<field name="name">Overdue Receipts</field>
<field name="res_model">hr.expense</field>
<field name="view_mode">list,pivot,form</field>
<field name="domain">[('receipt_overdue', '=', True), ('receipt_received', '=', False)]</field>
<field name="context">{'search_default_group_receipt_due': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No overdue receipts found!
</p><p>
This report shows all expenses that have been paid but the original receipts haven't been submitted yet.
</p>
</field>
</record>
<menuitem id="menu_hr_expense_overdue_receipts"
name="Overdue Receipts"
parent="hr_expense.menu_hr_expense_reports"
action="action_hr_expense_overdue_receipts"
sequence="20"/>
<record id="view_hr_expense_sheet_form_inherit_realization" model="ir.ui.view">
<field name="name">hr.expense.sheet.form.inherit.realization</field>
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form"/>
<field name="arch" type="xml">
<!-- Update standard Reset to Draft and Cancel buttons to include 'wait_post' -->
<xpath expr="//header//button[@name='action_reset_expense_sheets']" position="attributes">
<attribute name="invisible">state not in ['approve', 'post', 'done', 'cancel', 'wait_post']</attribute>
</xpath>
<xpath expr="//header//button[@name='action_refuse_expense_sheets']" position="attributes">
<attribute name="invisible">state not in ['submit', 'approve', 'post', 'wait_post']</attribute>
</xpath>
<xpath expr="//field[@name='state']" position="attributes">
<attribute name="statusbar_visible">draft,submit,approve,post,wait_post,done</attribute>
</xpath>
<xpath expr="//header" position="inside">
<button name="_compute_state"
string="Recompute Status"
type="object"
groups="base.group_erp_manager"
class="btn btn-secondary"
help="Force refresh the report status based on current payments and receipts."/>
</xpath>
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='name']" position="before">
<field name="sequence_name" column_invisible="not parent.id"/>
</xpath>
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='total_amount']" position="after">
<field name="realization_total_amount" optional="show" invisible="payment_mode != 'company_account'"/>
</xpath>
<xpath expr="//field[@name='expense_line_ids']/tree/field[@name='name']" position="after">
<field name="payment_mode" column_invisible="True"/>
<field name="realization_count" column_invisible="True"/>
<!-- Button to Add Receipt if none exists -->
<button name="action_create_realization"
string="Add Receipt"
type="object"
icon="fa-plus"
class="text-primary"
title="Add receipts for this expense"
invisible="payment_mode != 'company_account' or parent.state not in ['post', 'wait_post', 'done'] or realization_count != 0"/>
<!-- Button to View Receipts if already exist -->
<button name="action_view_realizations"
string="View Receipts"
type="object"
icon="fa-external-link"
class="text-success"
title="View linked receipts"
invisible="payment_mode != 'company_account' or parent.state not in ['post', 'wait_post', 'done'] or realization_count == 0"/>
</xpath>
</field>
</record>
<!-- Inherit Expense Report Tree View -->
<record id="view_hr_expense_sheet_tree_inherit_receipt" model="ir.ui.view">
<field name="name">hr.expense.sheet.tree.receipt</field>
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='state']" position="attributes">
<attribute name="decoration-warning">state == 'wait_post'</attribute>
</xpath>
<xpath expr="//field[@name='state']" position="before">
<field name="expense_sequences" optional="show"/>
<field name="amount_paid" optional="show" sum="Total Payment" string="Payment Total"/>
<field name="realization_total_amount" optional="show" sum="Total Realization"/>
<field name="receipt_status" widget="badge"
decoration-info="receipt_status == 'pending'"
decoration-success="receipt_status == 'received'"
decoration-muted="receipt_status == 'none'"
optional="show"/>
</xpath>
</field>
</record>
<!-- Inherit Expense Report Search View -->
<record id="hr_expense_sheet_view_search_inherit_receipt" model="ir.ui.view">
<field name="name">hr.expense.sheet.search.receipt</field>
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.hr_expense_sheet_view_search"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='my_reports']" position="after">
<separator/>
<filter string="Wait Post" name="filter_wait_post" domain="[('state', '=', 'wait_post')]"/>
<filter string="Pending Receipts" name="filter_receipt_pending" domain="[('receipt_status', '=', 'pending')]"/>
<filter string="Receipts Received" name="filter_receipt_received" domain="[('receipt_status', '=', 'received')]"/>
</xpath>
<xpath expr="//group[@name='group_filters']" position="inside">
<filter string="Receipt Status" name="group_receipt_status" context="{'group_by': 'receipt_status'}"/>
</xpath>
</field>
</record>
<!-- Update All Reports Action to include Wait Post in SearchPanel -->
<record id="hr_expense.action_hr_expense_sheet_all" model="ir.actions.act_window">
<field name="context">{ 'searchpanel_default_state': ["draft", "submit", "approve", "post", "wait_post", "done"] }</field>
</record>
<!-- Update My Reports Action to include Wait Post in SearchPanel if applicable -->
<record id="hr_expense.action_hr_expense_sheet_my_all" model="ir.actions.act_window">
<field name="context">{ 'searchpanel_default_state': ["draft", "submit", "approve", "post", "wait_post", "done"], 'search_default_my_reports': 1, 'search_default_not_refused_reports': 1 }</field>
</record>
</odoo>