Skip to content

[16.0][MIG] analytic brand#283

Open
pcastelovigo wants to merge 18 commits intoOCA:16.0from
flinq-ingenieria:16.0-mig-analytic_brand
Open

[16.0][MIG] analytic brand#283
pcastelovigo wants to merge 18 commits intoOCA:16.0from
flinq-ingenieria:16.0-mig-analytic_brand

Conversation

@pcastelovigo
Copy link
Copy Markdown

using oca-port

@pcastelovigo pcastelovigo mentioned this pull request Nov 22, 2025
8 tasks
Copy link
Copy Markdown
Contributor

@marielejeune marielejeune left a comment

Choose a reason for hiding this comment

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

Please see change commit that was applied in v18.
I think this is relevant in v16 too, as Odoo changed analytic accounts to analytic distributions.
4b05ed0

@pcastelovigo
Copy link
Copy Markdown
Author

Please see change commit that was applied in v18. I think this is relevant in v16 too, as Odoo changed analytic accounts to analytic distributions. 4b05ed0

yes, it seems it need to be adapted to distributions,
i'll try to do this week, thanks

@pcastelovigo pcastelovigo marked this pull request as draft November 24, 2025 08:52
@pcastelovigo pcastelovigo force-pushed the 16.0-mig-analytic_brand branch 3 times, most recently from cbdd3c3 to 9cb900a Compare November 28, 2025 17:52
@pcastelovigo pcastelovigo marked this pull request as ready for review November 28, 2025 17:54
@pcastelovigo
Copy link
Copy Markdown
Author

@marielejeune i think its ready

Copy link
Copy Markdown
Contributor

@marielejeune marielejeune left a comment

Choose a reason for hiding this comment

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

Please follow migration guidelines: https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-16.0

All the commit history is squashed, and the migration commit doesn't contain anything.

@pcastelovigo pcastelovigo force-pushed the 16.0-mig-analytic_brand branch from 9cb900a to faa39eb Compare December 2, 2025 12:45
Copy link
Copy Markdown
Contributor

@marielejeune marielejeune left a comment

Choose a reason for hiding this comment

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

LGTM.

Note that I'm currently facing some issues/difficulties using this module in v18.
The reason is that the analytic distribution is defined on the brand, while other composants use the analytic distribution models.

I think I will modify the module to add the brand dimension inside analytic distribution models too. I think this is something that could be useful for v16 too.

@pcastelovigo
Copy link
Copy Markdown
Author

LGTM.

Note that I'm currently facing some issues/difficulties using this module in v18. The reason is that the analytic distribution is defined on the brand, while other composants use the analytic distribution models.

I think I will modify the module to add the brand dimension inside analytic distribution models too. I think this is something that could be useful for v16 too.

I expected it to add automatically the analytic tag to account.moves using that brand but it does not work that way, it was also in the precedent versions.
I had code to add them with used with account_brand.. I'll check your work in the future

@marielejeune
Copy link
Copy Markdown
Contributor

marielejeune commented Dec 19, 2025

Hi @pcastelovigo,
Please check at my refactoring to use account analytic distribution models, ready here: #286

Copy link
Copy Markdown

@WesleyOliveira98 WesleyOliveira98 left a comment

Choose a reason for hiding this comment

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

LGTM

@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). 🤖

@sbejaoui
Copy link
Copy Markdown
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-283-by-sbejaoui-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Feb 26, 2026
Signed-off-by sbejaoui
@OCA-git-bot
Copy link
Copy Markdown
Contributor

@sbejaoui your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-283-by-sbejaoui-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

@sbejaoui your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-283-by-sbejaoui-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

Copy link
Copy Markdown

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root Cause

The test failure is caused by a missing or incorrect assignment of an analytic distribution to a brand in the analytic_brand module. This leads to a failure when the system tries to retrieve or use the default analytic account associated with a brand, particularly in contexts where analytic accounting is enabled.

2. Suggested Fix

In the analytic_brand module, ensure that when a brand is created or updated, the analytic_distribution field is properly assigned. Specifically, check the brand.py file (likely in models/brand.py) around line where analytic_distribution is handled. The assignment should be done during brand creation or update to ensure it's available for use in analytic accounting contexts.

3. Additional Code Issues

  • Missing validation: There is no validation to ensure that the analytic_distribution is valid or correctly formatted when assigned to a brand. This could lead to runtime errors if invalid data is passed.
  • Potential race condition: If multiple processes attempt to set the analytic_distribution simultaneously, there may be a race condition that results in incorrect data being saved.

4. Test Improvements

Add tests to cover the following scenarios using TransactionCase or SavepointCase:

  • Test brand creation with analytic distribution: Ensure that when a brand is created with an analytic distribution, it is correctly stored and retrievable.
  • Test brand update with analytic distribution: Verify that updating a brand's analytic distribution works correctly and persists the change.
  • Test usage in analytic accounting context: Ensure that the analytic distribution is correctly used as a default value in contexts where analytic accounting is active.
  • Test invalid analytic distribution: Validate that invalid or malformed analytic distributions are handled gracefully (e.g., by raising appropriate exceptions or logging warnings).

These tests should be tagged with @tag('analytic_brand') to ensure they are run as part of the module's test suite.


Environment: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA PR Reviewer + qwen3-coder:30b

@rvalyi
Copy link
Copy Markdown
Member

rvalyi commented Mar 14, 2026

/ocabot merge nobump

@OCA-git-bot
Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-283-by-rvalyi-bump-nobump, awaiting test results.

OCA-git-bot added a commit that referenced this pull request Mar 14, 2026
Signed-off-by rvalyi
@OCA-git-bot
Copy link
Copy Markdown
Contributor

@rvalyi your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-283-by-rvalyi-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

@OCA-git-bot
Copy link
Copy Markdown
Contributor

@rvalyi your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-283-by-rvalyi-bump-nobump.

After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red.

Copy link
Copy Markdown

@marcos-mendez marcos-mendez left a comment

Choose a reason for hiding this comment

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

Automated Review -- Tests Failed

1. Root cause of the test failure

The test failure is caused by a missing Python dependency openupgradelib, which is declared in the module's manifest under external_dependencies but not installed in the test environment. This prevents Odoo from loading the analytic_brand module.

2. Suggested fix

Ensure that openupgradelib is installed in the test environment. If using a CI or test runner like odoo-test, add openupgradelib to the list of required Python packages. Alternatively, if the migration script is not essential for basic functionality, consider removing openupgradelib from external_dependencies and moving the migration logic to a separate, optional upgrade script.

3. Additional code issues

  • Missing field definition in res_brand.py: The model inherits from analytic.mixin but does not explicitly define the analytic_distribution field. This may lead to unexpected behavior or missing fields in views.
    • File: analytic_brand/models/res_brand.py
    • Suggestion: Add explicit field definition for analytic_distribution or ensure analytic.mixin properly defines it.

4. Test improvements

To better cover this module:

  • Add a TransactionCase test to verify that analytic_distribution is correctly set on a brand and used in analytic accounting contexts.
  • Add a SavepointCase test to validate the migration script (pre-migrate.py) logic, especially the ALTER TABLE and UPDATE SQL queries.
  • Add a test case that checks field visibility or default values in views when analytic.mixin is used.
  • Use tagged tests for migration-related logic to ensure they are only run when needed.

Example test snippet:

def test_analytic_distribution_default(self):
    brand = self.env['res.brand'].create({'name': 'Test Brand'})
    self.assertEqual(brand.analytic_distribution, {})

This follows OCA patterns for testing extension hooks and field behavior.


⏰ PR Aging Alert

This PR by @pcastelovigo has been open for 112 days (3 months).

Every ignored PR is a contributor who might not come back. Review time matters. (OCA Aging Report)


Reciprocal Review Request

Hi everyone! I found some test failures on this PR and left detailed feedback above. I am happy to discuss or help debug. In the meantime, if any of you get a chance, I would appreciate a look at my open PR(s):

My open PRs across OCA:

Reviewing each other's work helps the whole community move forward. Thank you!


Environment via OCA Neural Reviewer: Minikube + K8s Job + oca-ci/py3.10-odoo16.0 | Odoo 16.0
Automated review by OCA Neural Reviewer + qwen3-coder:30b

@pcastelovigo
Copy link
Copy Markdown
Author

CI fix in #296

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.