-
-
Notifications
You must be signed in to change notification settings - Fork 798
Description
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:
- Create an Odoo v12 database, with an
account.journalrecord with thegroup_invoice_linesboolean set to True - Create an
account.invoicewith several lines of the same product, then post the invoice to create amovewith a grouped invoice line - Migrate to Odoo 13.0
- Check the newly created
account.move.linerecords and theiraccount_root_idfield.
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.linerecords, after theaccount.invoice.linetable was merged with it. - You could assign the
account_root_idfield within themigration_invoice_movesmethod.