Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] account_financial_report: Remove inactive analytic account relations #1237

Draft
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

sergiobstoj
Copy link
Member

@sergiobstoj sergiobstoj commented Oct 18, 2024

When an analytic account is set to inactive (active=False), the relation with Journal Item is not automatically removed. This causes inactive analytic accounts to still appear linked to journal items when grouping by Analytic Account.

  • Current behavior before PR

    • When using the edition mode in tree view from Journal Items, when removing an Analytic Account, the field analytic_account_ids is updated.
    • Here is the behavior with active analytic accounts.
      test_with_active_account.webm
    • Inactive analytic accounts are not being unlinked from account.move.line records.
      test_with_inactive_account.webm
  • Behavior with PR

    • With this PR, the relation is properly removed and Journal Item is not linked to inactive account
      test_with_pr.webm

Changes

  • Remove self.analytic_account_ids = False
  • Replace with: self.with_context(active_test=False).analytic_account_ids = [(6, 0, [])] to consider archived analytic account.

@sergiobstoj sergiobstoj force-pushed the 16.0-fix-compute_analytic_account_ids branch from 6d45a8b to f7d69e7 Compare October 18, 2024 11:15
@pedrobaeza pedrobaeza added this to the 16.0 milestone Oct 18, 2024
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

The current behavior is correct, as you have to see the historical data of that account, no matter if currently the analytic account is archived. It's the same as if you archive a partner.

@sergiobstoj
Copy link
Member Author

sergiobstoj commented Oct 21, 2024

Hi @pedrobaeza

But if we attempt to remove from a Journal Item the archived Analytic Account, shouldn't it be unlinked?

That's the only case being considered here. If we don't remove an archived Analytic Account, the relation still remains.

two-archived-accounts.webm

@pedrobaeza
Copy link
Member

Why don't you put ondelete="cascade" instead?

@sergiobstoj sergiobstoj force-pushed the 16.0-fix-compute_analytic_account_ids branch 3 times, most recently from 503c6bc to f6053f7 Compare October 21, 2024 17:28
@sergiobstoj
Copy link
Member Author

ondelete="cascade" does not accomplish the desired behaviour

@pedrobaeza
Copy link
Member

Yeah, but I'm afraid this is not valid either. As said, an archived analytic account must still be shown in financial reports.

@luc-demeyer
Copy link

I agree with Pedro on this topic.

@sergiobstoj sergiobstoj force-pushed the 16.0-fix-compute_analytic_account_ids branch from f6053f7 to 784c2ad Compare October 24, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants