Skip to content

[12.0 -> 13.0] account_root_id field unassigned on account.move.line records ported from account.invoice.line #5552

@Honeyxilia

Description

@Honeyxilia

Module

account post-migration script

Describe the bug

On account.invoice.line records ported to account.move.line without having been matched to a account.move.line record, the account_root_id field is not assigned.
Indeed, in the post-migration.py script, the assignment of account_root_id fields to account.move.line records happens before the fusion between the account.invoice.line and account.move.line tables :

def fill_account_move_line_missing_fields(env):
    openupgrade.logged_query(env.cr, """
        UPDATE account_move_line aml
        SET account_root_id = aa.root_id
        FROM account_account aa
        WHERE aa.id = aml.account_id
    """)
    openupgrade.logged_query(env.cr, """
        UPDATE account_move_line aml
        SET tax_group_id = at.tax_group_id
        FROM account_tax at
        WHERE at.id = aml.tax_line_id
    """)

# (...)

@openupgrade.migrate()
def migrate(env, version):
    # (...)
    fill_account_move_line_missing_fields(env)
    migration_invoice_moves(env)
    # (...)

This causes an issue in the view_account_move_line_filter account.move.line view, with the sidebar account root filter, since these fields are unassigned when the account.invoice.line records are recreated from a SQL request in the account.move.line table

To Reproduce

Affected versions:

Steps to reproduce the behavior:

  1. Create an Odoo v12 database, with an account.journal record with the group_invoice_lines boolean set to True
  2. Create an account.invoice with several lines of the same product, then post the invoice to create a move with a grouped invoice line
  3. Migrate to Odoo 13.0
  4. Check the newly created account.move.line records and their account_root_id field.

Expected behavior
During the migration, the account_root_id field should be assigned to newly created account.move.line records created from account.invoice.line records.

Ideas of implementation :

  • You could swap the two mentionned methods above, so that the newly created fields are added to all account.move.line records, after the account.invoice.line table was merged with it.
  • You could assign the account_root_id field within the migration_invoice_moves method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions