Skip to content

Commit

Permalink
[OU-FIX] hr_expense: fail when account_journal_lock_date
Browse files Browse the repository at this point in the history
  • Loading branch information
remytms committed Sep 30, 2024
1 parent 9af4744 commit 42fb52e
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from openupgradelib import openupgrade


def _fill_payment_state(env):
def _fill_payment_state(env, bypass_journal_lock_date=False):
openupgrade.logged_query(
env.cr,
"""
Expand All @@ -23,7 +23,9 @@ def _fill_payment_state(env):
# v14 these ones were not computed being of type `entry`, which changes now
# on v15 if the method `_payment_state_matters` returns True, which is the
# case for the expense moves
for move in env["hr.expense.sheet"].search([]).account_move_id:
for move in env["hr.expense.sheet"].with_context(
bypass_journal_lock_date=bypass_journal_lock_date
).search([]).account_move_id:
# Extracted and adapted from _compute_amount() in account.move
new_pmt_state = "not_paid" if move.move_type != "entry" else False
total_to_pay = total_residual = 0.0
Expand All @@ -48,7 +50,10 @@ def _fill_payment_state(env):

@openupgrade.migrate()
def migrate(env, version):
_fill_payment_state(env)
bypass_journal_lock_date = openupgrade.is_module_installed(
env.cr, "account_journal_lock_date",
)
_fill_payment_state(env, bypass_journal_lock_date)
openupgrade.load_data(env.cr, "hr_expense", "15.0.2.0/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr, "hr_expense", ["hr_expense_template_register"]
Expand Down

0 comments on commit 42fb52e

Please sign in to comment.