Skip to content

[18.0][REF] analytic_brand: make use of account analytic distribution models:#286

Merged
OCA-git-bot merged 4 commits intoOCA:18.0from
acsone:18.0-analytic_brand-analytic_distribution_model-mle
Feb 26, 2026
Merged

[18.0][REF] analytic_brand: make use of account analytic distribution models:#286
OCA-git-bot merged 4 commits intoOCA:18.0from
acsone:18.0-analytic_brand-analytic_distribution_model-mle

Conversation

@marielejeune
Copy link
Copy Markdown
Contributor

@marielejeune marielejeune commented Dec 18, 2025

Add brands as a dimension in account analytic distribution models, instead of defining the analytic distribution directly on the brand. This makes the code more standard, allowing to use the standard flow of analytic distribution models everywhere where they will be used.

This PR contains several commits:

  • Refactor analytic_brand to include brands as a dimension in analytic distribution models. Include a migration script for existing analytic distributions defined on brands.
  • Refactor contract_brand to make use of the standard analytic distribution models on contracts.
  • Add account_analytic_brand to make use of the standard analytic distribution models on account moves.
  • Add sale_analytic_brand to make use of the standard analytic distribution models on sale orders.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @sbejaoui,
some modules you are maintaining are being modified, check this out!

@marielejeune marielejeune force-pushed the 18.0-analytic_brand-analytic_distribution_model-mle branch 3 times, most recently from 2e8bdd6 to 140dfb9 Compare December 19, 2025 15:18
@marielejeune marielejeune marked this pull request as ready for review December 19, 2025 15:24
@marielejeune marielejeune force-pushed the 18.0-analytic_brand-analytic_distribution_model-mle branch from 140dfb9 to cfd61d2 Compare December 19, 2025 16:05
@pcastelovigo
Copy link
Copy Markdown

pcastelovigo commented Dec 26, 2025

Works well, unfortunately backporting this to 16.0 implies doing almost completely different modules (-- I have it working! https://github.com/flinq-ingenieria/brand/tree/16.0-analytic_brand-analytic_distribution_model-mle) as base methods differs too much

Copy link
Copy Markdown

@pcastelovigo pcastelovigo left a comment

Choose a reason for hiding this comment

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

LGTM

@pcastelovigo
Copy link
Copy Markdown

This PR significantly improves the integration of brand with analytic accounting.

In my humble opinion, the proposed approach is much closer to the functionality users actually expect.

For version 16.0, I proposed a conservative migration that followed the previous behavior adapted to analytic distributions.

What to do for version 17 is now up to the community to decide.

Copy link
Copy Markdown

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

LGTM. Two remarks

# Copyright 2025 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A little bit less spaces ? 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


brand_id = fields.Many2one(
"res.brand",
ondelete="cascade",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure about that. Maybe restrict in this case, no ? And we archive brands instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, done

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Add brands as a dimension in account analytic distribution models,
instead of defining the analytic distribution directly on the brand.
This makes the code more standard, allowing to use the standard flow
of analytic distribution models everywhere where they will be used.
…tion models:

As brands are a dimension in account analytic distribution models,
extend the methods of account.analytic.mixin to make it work for contracts
@marielejeune marielejeune force-pushed the 18.0-analytic_brand-analytic_distribution_model-mle branch from cfd61d2 to 096575f Compare February 26, 2026 11:05
Copy link
Copy Markdown

@AnizR AnizR left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

But, I am a bit puzzled by the comment in sale_analytic_brand/models/sale_order_line.py:27, it is not optimal to call twice the _get_distribution (done once in the super) and if I do a patch on Odoo I won't need your module sale_analytic_brand, right?

@marielejeune marielejeune force-pushed the 18.0-analytic_brand-analytic_distribution_model-mle branch from 096575f to 4e63285 Compare February 26, 2026 12:09
@marielejeune marielejeune force-pushed the 18.0-analytic_brand-analytic_distribution_model-mle branch from 4e63285 to 8f2f92d Compare February 26, 2026 12:09
@marielejeune
Copy link
Copy Markdown
Contributor Author

Code looks good to me.

But, I am a bit puzzled by the comment in sale_analytic_brand/models/sale_order_line.py:27, it is not optimal to call twice the _get_distribution (done once in the super) and if I do a patch on Odoo I won't need your module sale_analytic_brand, right?

Thanks for your comment. I've changed the comment in the code to be more explicit: The code I'm writing is improving the Odoo method by replacing the hardcoded dict by a method that allows to inject new values in this dict.

Copy link
Copy Markdown
Contributor

@sbejaoui sbejaoui left a comment

Choose a reason for hiding this comment

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

LGTM, code review

@sbejaoui
Copy link
Copy Markdown
Contributor

/ocabot merge major

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-286-by-sbejaoui-bump-major, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit fde478b into OCA:18.0 Feb 26, 2026
7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 62c89e8. 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.

6 participants