-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
[14.0][FIX] account_financial_report: partner trial balance: sort by partner name #914
[14.0][FIX] account_financial_report: partner trial balance: sort by partner name #914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and approved !
@alexis-via are you going to forward-port this patch to v15 if I launch the merge command? |
This PR has the |
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
@alexis-via please resolver the conflicts and fw-port it to upper versions. |
646a27a
to
808c778
Compare
I propose that we wait until 2025 to merge this fix because:
|
BTW, the bug is still present in v14 with up-to-date code of the module account_financial_report, so this PR is still relevant. |
9d1c02b
to
a77066e
Compare
a77066e
to
67147d7
Compare
This PR also fixes a crash in partner balance XLSX report. The crash is obsvious when you read the backtrace: confusion between ID and recordset. So I added a browse() to fix the crash.
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
b4b49d8
to
7e7adaf
Compare
rebased. |
/ocabot merge minor |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 88d2784. Thanks a lot for contributing to OCA. ❤️ |
Please fw-port it to upper versions. You have even 2 even versions up there. |
@pedrobaeza I made all the forward ports |
On v14, trial balance report with "show partners details" = True:
![bug_financial_report-before](https://user-images.githubusercontent.com/1157917/190734315-a1aec614-f0b6-4350-9459-9f9b447d14ae.png)
BEFORE
AFTER:
![bug_financial_report-after](https://user-images.githubusercontent.com/1157917/190734534-04689f70-2753-4faa-a37d-2814085f445f.png)
More info:
With the current implementation, the partners that have debit = credit = 0 are always at the end. In the "before" screenshot, partner AAcorp has an initial balance, but it has debit = credit = 0 so it is displayed at the end.
With the current implementation, each account displays 2 blocks of partners, each block being in alphabetical order:
In python 3.7+, dictionary order is guaranteed to be insertion order. (warning: from my experience, insertion order may be different from print order !).
The trial balance report is built by the dictionary "total_amount". So, for a particular account, the order of the partners is the order of insertion of that partner in the total_amount[account_id] dictionary. This is handled by the method _compute_partner_amount() in report/trial_balance.py cf https://github.com/OCA/account-financial-reporting/blob/14.0/account_financial_report/report/trial_balance.py#L249 In that method, there is a first loop on tb_period_prt that inserts partner_id keys in total_amount[account_id] and a second loop on tb_initial_prt which inserts partner_id keys in total_amount[account_id] if that partner wasn't already inserted in the first loop. This explains the bug.
I'm not familiar with the code of account_financial_report, so I'm not sure that this PR is the best fix for the problem. But it solves the bug.