Skip to content

Commit

Permalink
[OU-FIX] account: fill payment_method_line_id
Browse files Browse the repository at this point in the history
  • Loading branch information
remytms committed Aug 8, 2024
1 parent e428b19 commit ff1363a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions openupgrade_scripts/scripts/account/15.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ def _fill_payment_destination_journal(env):
)


def _fill_account_payment_payment_method_line_id(env):
"""Compute and store payment_method_line_id for account_payment"""
payments = env["account.payment"].search([])
# code from account_payment._compute_payment_method_line_id()
for pay in payments:
available_payment_method_lines = pay.available_payment_method_line_ids

# Select the first available one by default.
if pay.payment_method_line_id in available_payment_method_lines:
pay.payment_method_line_id = pay.payment_method_line_id
elif available_payment_method_lines:
pay.payment_method_line_id = available_payment_method_lines[0]._origin
else:
pay.payment_method_line_id = False


def set_res_company_account_setup_taxes_state_done(env):
taxes = env["account.tax"].read_group([], ["company_id"], ["company_id"])
for tax in taxes:
Expand Down Expand Up @@ -79,6 +95,7 @@ def _handle_website_legal_page(env):
def migrate(env, version):
_fill_account_analytic_line_category(env)
_fill_payment_destination_journal(env)
_fill_account_payment_payment_method_line_id(env)
set_res_company_account_setup_taxes_state_done(env)
openupgrade.load_data(env.cr, "account", "15.0.1.2/noupdate_changes.xml")
openupgrade.delete_record_translations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ account / account.payment / payment_method_id (many2one) : now re

account / account.payment / payment_method_line_id (many2one): NEW relation: account.payment.method.line, isfunction: function, stored
# DONE: pre-migration: fast filled value for payment_method_line_id
# DONE: post-migration: compute stored values for payment_method_line_id

account / account.payment.method / _order : _order is now 'id' ('sequence')
account / account.payment.method / sequence (integer) : DEL
Expand Down

0 comments on commit ff1363a

Please sign in to comment.