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

Aperta
#5,552 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
40/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, sql
Ambito
backend, databases

Direzione di ricerca

The fix lives in the account module's post-migration script, in fill_account_move_line_missing_fields and the migrate function, which currently run that fill before migration_invoice_moves. Read the ordering in migrate, then check account_root_id on rows that came from account.invoice.line after a migration run. Done means those migrated lines carry the root account id, so the root filter in view_account_move_line_filter works.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

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.
Lingua principale
Python
Stelle
995
Fork
837
Merge medio
5g 6h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OCA/OpenUpgrade

Tutte le issue di OCA/OpenUpgrade

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.