Skip to content

[14.0][OU-FIX] fix account.partial.reconcile currency#5438

Merged
MiquelRForgeFlow merged 1 commit intoOCA:14.0from
coopiteasy:14.0-ou_fix-account_partial_reconcile_currency_id
Nov 5, 2025
Merged

[14.0][OU-FIX] fix account.partial.reconcile currency#5438
MiquelRForgeFlow merged 1 commit intoOCA:14.0from
coopiteasy:14.0-ou_fix-account_partial_reconcile_currency_id

Conversation

@huguesdk
Copy link
Copy Markdown
Member

@huguesdk huguesdk commented Nov 5, 2025

fix queries pre-filling the debit_currency_id and credit_currency_id fields of account.partial.reconcile records: debit_move_id and credit_move_id are many2one fields to account.move.line, not to account.move. this resulted in null columns, ignoring the records when computing account.move.line.amount_residual in odoo 16.

here is how to fix existing data:

self.env.cr.execute(
    """
    update account_partial_reconcile as apr
    set debit_currency_id = coalesce(aml.currency_id, rc.currency_id)
    from account_move_line as aml,
        res_company as rc
    where
        debit_currency_id is null and
        aml.id = apr.debit_move_id and
        rc.id = aml.company_id
    """
)
self.env.cr.execute(
    """
    update account_partial_reconcile as apr
    set credit_currency_id = coalesce(aml.currency_id, rc.currency_id)
    from account_move_line as aml,
        res_company as rc
    where
        credit_currency_id is null and
        aml.id = apr.credit_move_id and
        rc.id = aml.company_id
    """
)
self.env["account.move.line"].search(
    [
        ("reconciled", "=", False),
        "|",
        ("matched_credit_ids", "!=", False),
        ("matched_debit_ids", "!=", False),
    ]
)._compute_amount_residual()

fix queries pre-filling the debit_currency_id and credit_currency_id
fields of account.partial.reconcile records: debit_move_id and
credit_move_id are many2one fields to account.move.line, not to
account.move. this resulted in null columns, ignoring the records when
computing account.move.line.amount_residual in odoo 16.
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @pedrobaeza, @StefanRijnhart, @MiquelRForgeFlow,
some modules you are maintaining are being modified, check this out!

Copy link
Copy Markdown

@remytms remytms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Copy Markdown
Contributor

@MiquelRForgeFlow MiquelRForgeFlow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM! (blame to @etobella 😄)

Copy link
Copy Markdown
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

@MiquelRForgeFlow MiquelRForgeFlow merged commit 29925d6 into OCA:14.0 Nov 5, 2025
2 checks passed
@huguesdk
Copy link
Copy Markdown
Member Author

huguesdk commented Nov 5, 2025

wow, that was a super fast merge, thanks!

@etobella in your defense, the fields are very badly named. it took me some time to notice it. this states the importance of naming fields in a meaningful way. you can transfer your blame to odoo. ☺️

@etobella
Copy link
Copy Markdown
Member

etobella commented Nov 5, 2025

Don't worry, I didn't took it badly, it was my mistake, but well, for this reason we have a community. Altogether, we are able to find solutions and fix the mistakes on the software 😉

@pedrobaeza pedrobaeza added this to the 14.0 milestone Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants