Skip to content

[15.0][IMP] account_financial_report: Add grouping by analytical account in Trial balance#1151

Merged
OCA-git-bot merged 2 commits into
OCA:15.0from
Tecnativa:15.0-imp-account_financial_report-TT48969-v3
Oct 19, 2024
Merged

[15.0][IMP] account_financial_report: Add grouping by analytical account in Trial balance#1151
OCA-git-bot merged 2 commits into
OCA:15.0from
Tecnativa:15.0-imp-account_financial_report-TT48969-v3

Conversation

@victoralmau

@victoralmau victoralmau commented May 2, 2024

Copy link
Copy Markdown
Member

Changes done:

  • Change t-esc and t-raw to t-out fromTrial Balance report
  • Refactor from Trial Balance
  • Add grouping by analytical account in Trial balance

ejemplo

Please @pedrobaeza can you review it?

@Tecnativa TT48969

@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch from 82d8c9a to 513fbe2 Compare May 3, 2024 07:06
@victoralmau victoralmau changed the title [15.0][WIP] account_financial_report: Add grouping by analytical account in Trial balance [15.0][IMP] account_financial_report: Add grouping by analytical account in Trial balance May 3, 2024
@victoralmau victoralmau marked this pull request as ready for review May 3, 2024 07:08
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch from 513fbe2 to 0073e67 Compare May 3, 2024 07:11
@victoralmau

Copy link
Copy Markdown
Member Author

Ping @pedrobaeza

@pedrobaeza pedrobaeza added this to the 15.0 milestone May 31, 2024

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On a test on runboat, all the groups by analytic accounting are putting the "Undistributed loss/gain results" with value 0 (account 129 in Spanish CoA, 9999999 in the sample CoA), and even more as I checked the option "Hide accounts at 0" (but it should be independent - it mustn't never appear).

Comment thread account_financial_report/report/trial_balance.py Outdated
Comment thread account_financial_report/wizard/trial_balance_wizard.py Outdated
Comment thread account_financial_report/wizard/trial_balance_wizard_view.xml Outdated
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch 2 times, most recently from 766f929 to f5c4d74 Compare June 4, 2024 12:40
@victoralmau victoralmau marked this pull request as draft June 4, 2024 12:41
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch 3 times, most recently from b654537 to 954c0ae Compare June 5, 2024 09:13
@victoralmau

Copy link
Copy Markdown
Member Author

Changes done. Complete refactoring and added the option of grouping by analytical account in an extra commit.

@victoralmau victoralmau marked this pull request as ready for review June 5, 2024 09:17
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch 3 times, most recently from 035ed43 to f797579 Compare June 12, 2024 14:25
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch 9 times, most recently from 55f272e to 5ea6a1f Compare June 17, 2024 14:31
@victoralmau

Copy link
Copy Markdown
Member Author

Finally all changes are done and tested in a customer use case.

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The refactoring is not successful, as the idea is to reduce the number or methods and arguments, and I still see a lot of both. When I told you #1151 (comment), it was to remove all the parameters except one. And I think most of the domains can be shared and reduced, as it's the same over and over...

Comment thread account_financial_report/tests/test_trial_balance.py Outdated
trial_balance = res_data["trial_balance"]
check_partner_receivable = self.check_partner_in_report(
self.account100.id, self.partner.id, total_amount
self.account100.id, self.partner.id, trial_balance

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you use fixed amounts? These tests are wicked this way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed amounts? This was (and is) trying to pull the corresponding report line filtering by some data (account and partner).

@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch from 5ea6a1f to f25125a Compare June 19, 2024 08:05
@victoralmau

Copy link
Copy Markdown
Member Author

The refactoring is not successful, as the idea is to reduce the number or methods and arguments, and I still see a lot of both. When I told you #1151 (comment), it was to remove all the parameters except one. And I think most of the domains can be shared and reduced, as it's the same over and over...

This refactoring is not enough? If you prefer i can delete the report completely and do it again, or change it as much as you want with many more hours, but the problem will always be the same, there is NOT enough data (neither in the tests nor creating them manually) to test that all the use cases work correctly and nothing is broken, so you always have to test these changes in "real environments", the same happens with other reports, it is absolutely frustrating.

@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch 4 times, most recently from 9216b90 to 7d678a9 Compare June 19, 2024 14:36
@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch from 7d678a9 to 40c2975 Compare July 3, 2024 12:08
@victoralmau

Copy link
Copy Markdown
Member Author

New approach done (3rd) with a clear objective: not to change the existing behavior, only to add a new one.

Changes done (and the reason):

  • Added grouped_by field in wizard to group by analytical account.
  • Fields are added to the groupby when you want to group and queries are done to get the data by analytical accounts.
  • Set the grouped data in total_amount (to use these data later).
  • The data currently used in the report: trial_balance and total_amount have a fixed structure on account that we do not want to change (we want to keep the existing operation so far), set trial_balance_grouped to obtain the data grouped by analytical account and account + total_amount_grouped (to represent the sum of all totals). They are also used in the XLS export.
  • A different way has been set in template when you want to group to show the data.
  • It has been set in the template to add analytic_account_id to the domain when clicking on a data if we are grouping.

<t t-call="account_financial_report.report_trial_balance_filters" />
<div class="act_as_table list_table" style="margin-top: 10px;" />
<!-- Display account lines -->
<t t-set="aml_domain_extra" t-value="[]" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of having to add this extra domain everywhere, can't we add the extra bits in the already present domain variable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have changed to add aml_domain_extra only where it is really needed.

Just for clarification, you want to then add all this code:

<t
    t-set="aml_domain_extra"
    t-if="grouped_item['id'] > 0"
    t-value="[('analytic_account_id', '=', grouped_item['id'])]"
/>
<t
    t-set="aml_domain_extra"
    t-else=""
    t-value="[('analytic_account_id', '=', False)]"
/>

in the 7 places where aml_domain_extra is currently added (in this case I have set global variable precisely to reduce code and do the same thing that aml_domain_common does for example).

@acysos

acysos commented Jul 18, 2024

Copy link
Copy Markdown
Member

Hello,

Functionally it is correct. I have tested it.

Greetings

@victoralmau victoralmau force-pushed the 15.0-imp-account_financial_report-TT48969-v3 branch from 40c2975 to 950a214 Compare July 18, 2024 12:55
@victoralmau

Copy link
Copy Markdown
Member Author

Ping @pedrobaeza

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/ocabot merge major

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 15.0-ocabot-merge-pr-1151-by-pedrobaeza-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 0b64dd8 into OCA:15.0 Oct 19, 2024
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 259ab9f. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants