feat: add is_expense_payment flag and hide reversal button on expense payment journal entries

This commit is contained in:
Suherdy Yacob 2026-04-30 21:48:13 +07:00
parent fce5f0e286
commit 7da10ccb15
3 changed files with 30 additions and 1 deletions

View File

@ -14,6 +14,7 @@
'views/hr_expense_payment_wizard_views.xml',
'views/hr_expense_kiosk_templates.xml',
'views/res_config_settings_views.xml',
'views/account_move_views.xml',
],
'assets': {
'hr_expense_account_split.assets_public_kiosk': [

View File

@ -1,8 +1,19 @@
from odoo import models, api
from odoo import models, fields, api
class AccountMove(models.Model):
_inherit = 'account.move'
is_expense_payment = fields.Boolean(
string="Is Expense Payment",
compute="_compute_is_expense_payment",
store=True,
)
@api.depends('payment_id.expense_sheet_id')
def _compute_is_expense_payment(self):
for move in self:
move.is_expense_payment = bool(move.payment_id and move.payment_id.expense_sheet_id)
def _get_hr_expense_base_class(self):
""" Returns the hr_expense class in the MRO to jump over it. """
mro = type(self).mro()

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Override account move form to hide reverse button for expense payments -->
<record id="view_move_form_inherit_expense_payment" model="ir.ui.view">
<field name="name">account.move.form.inherit.expense.payment</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='%(account.action_view_account_move_reversal)d']" position="attributes">
<attribute name="invisible">move_type != 'entry' or state != 'posted' or payment_state == 'reversed' or is_expense_payment</attribute>
</xpath>
<xpath expr="//sheet" position="inside">
<field name="is_expense_payment" invisible="1"/>
</xpath>
</field>
</record>
</odoo>