oca-hr/odoo-bringout-oca-hr-expense-hr_expense_payment/hr_expense_payment/hooks.py
Ernad Husremovic dfcda4100c Move all OCA HR modules from oca-technical to dedicated oca-hr submodule
Reorganized 67 HR-related modules for better structure:
- Moved all odoo-bringout-oca-hr-* packages from packages/oca-technical/
- Now organized in dedicated packages/oca-hr/ submodule
- Includes attendance, expense, holiday, employee, and contract modules
- Maintains all module functionality while improving project organization

This creates a cleaner separation between general technical modules
and HR-specific functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:11:28 +02:00

18 lines
739 B
Python

# Copyright 2019 Tecnativa - Ernesto Tejeda
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
"""Trying to fill the source expense sheet in payments"""
env = api.Environment(cr, SUPERUSER_ID, {})
sheets = env["hr.expense.sheet"].search([("payment_mode", "=", "own_account")])
for sheet in sheets:
amls = sheet.account_move_id.mapped("line_ids")
reconcile = amls.mapped("full_reconcile_id")
aml_payment = reconcile.mapped("reconciled_line_ids").filtered(
lambda r: r not in amls
)
payment = aml_payment.mapped("payment_id")
payment.write({"expense_sheet_ids": sheet.ids})