Skip to content

[16.0] [IMP] subscription_oca adding analytic_distribution#1210

Open
eLBati wants to merge 2 commits intoOCA:16.0from
eLBati:16.0-subscription-analytic
Open

[16.0] [IMP] subscription_oca adding analytic_distribution#1210
eLBati wants to merge 2 commits intoOCA:16.0from
eLBati:16.0-subscription-analytic

Conversation

@eLBati
Copy link
Member

@eLBati eLBati commented Mar 11, 2025

Propagating from sale orders and to invoices

@eLBati eLBati force-pushed the 16.0-subscription-analytic branch 2 times, most recently from 4d01ca5 to 3f4de81 Compare March 11, 2025 16:45
Copy link

@rrebollo rrebollo left a comment

Choose a reason for hiding this comment

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

Code Review: Great work! The code looks good to me (LGTM). Thank you for your contribution! We are testing this with a real customer. I'll talk with the functional team and they might do the review too.

Copy link

@rrebollo rrebollo Mar 17, 2025

Choose a reason for hiding this comment

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

Aren't You forcing an analytic distribution even if there wasn't one in the source sale.order.line? Pardon my ignorance. Would you be so kind to explain me the use case?

Choose a reason for hiding this comment

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

I checked something similar it's done in built-in sale_order addon in order to prepare invoice lines but: is this really analogue ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Method get_subscription_line_values is called to create a new subscription when sold (from sale.order): if sale.order.line has got an analytic_distribution then set it in subscription line, otherwise use the analytic account of Generated Project

Copy link

@AinohaBH AinohaBH left a comment

Choose a reason for hiding this comment

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

LGTM!
The sales flow linked to an analytical account: sales order → subscription → invoicing is executed correctly. And the gross margin is correctly reflected in the analytical accounts.

@OCA-git-bot
Copy link
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). 🤖

@eLBati
Copy link
Member Author

eLBati commented Apr 3, 2025

@carlos-domatix merge? Thanks!

@eLBati
Copy link
Member Author

eLBati commented Apr 15, 2025

@OCA/project-service-maintainers merge? Thanks!

@eLBati eLBati force-pushed the 16.0-subscription-analytic branch from 3f4de81 to d622fb8 Compare May 21, 2025 13:42
"price_subtotal": self.price_subtotal,
"analytic_distribution": self.analytic_distribution
if self.analytic_distribution
else {self.project_id.analytic_account_id.id: 100}
Copy link
Member

Choose a reason for hiding this comment

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

Does this need project to be installed?

Copy link
Contributor

Choose a reason for hiding this comment

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

@eLBati Agree with @tarteo here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, thanks, we are going to put the changes in a dedicated module

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed this and created #1270

tarteo added a commit to tarteo/contract that referenced this pull request May 22, 2025
tarteo pushed a commit to tarteo/contract that referenced this pull request May 27, 2025
[IMP] subscription_oca: Use read_group for subscription count

Apply changes of OCA#1058

Apply changes of OCA#1224

Apply changes of OCA#1210

Apply changes of OCA#1167

subscription_oca: use get_formview_action

Fix close_reason_id visibility
tarteo pushed a commit to tarteo/contract that referenced this pull request May 27, 2025
[IMP] subscription_oca: Use read_group for subscription count

Apply changes of OCA#1058

Apply changes of OCA#1224

Apply changes of OCA#1210

Apply changes of OCA#1167

subscription_oca: use get_formview_action

Fix close_reason_id visibility
@rousseldenis rousseldenis added this to the 16.0 milestone Jun 10, 2025
LorenzoC0 added a commit to LorenzoC0/contract that referenced this pull request Jul 1, 2025
eLBati pushed a commit to eLBati/contract that referenced this pull request Jul 2, 2025
eLBati pushed a commit to eLBati/contract that referenced this pull request Jul 2, 2025
@eLBati eLBati force-pushed the 16.0-subscription-analytic branch from cb6afd5 to 187d1ab Compare July 2, 2025 08:02
eLBati pushed a commit to eLBati/contract that referenced this pull request Jul 2, 2025
@eLBati eLBati force-pushed the 16.0-subscription-analytic branch from 187d1ab to d4c3e34 Compare July 2, 2025 08:21
Copy link
Member

@tarteo tarteo left a comment

Choose a reason for hiding this comment

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

Thanks!

eLBati and others added 2 commits July 17, 2025 06:22
Propagating from sale orders and to invoices
@eLBati eLBati force-pushed the 16.0-subscription-analytic branch from d4c3e34 to 4657b20 Compare July 17, 2025 04:22
tarteo pushed a commit to tarteo/contract that referenced this pull request Sep 17, 2025
[IMP] subscription_oca: Use read_group for subscription count

Apply changes of OCA#1058

Apply changes of OCA#1224

Apply changes of OCA#1210

Apply changes of OCA#1167

subscription_oca: use get_formview_action

Fix close_reason_id visibility

Apply suggestions from review
tarteo pushed a commit to tarteo/contract that referenced this pull request Sep 17, 2025
[IMP] subscription_oca: Use read_group for subscription count

Apply changes of OCA#1058

Apply changes of OCA#1224

Apply changes of OCA#1210

Apply changes of OCA#1167

subscription_oca: use get_formview_action

Fix close_reason_id visibility

Apply suggestions from review

Add "odoo 18"-like icon
tarteo pushed a commit to tarteo/contract that referenced this pull request Sep 17, 2025
[IMP] subscription_oca: Use read_group for subscription count

Apply changes of OCA#1058

Apply changes of OCA#1224

Apply changes of OCA#1210

Apply changes of OCA#1167

subscription_oca: use get_formview_action

Fix close_reason_id visibility

Apply suggestions from review

Add "odoo 18"-like icon
@github-actions
Copy link

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.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 16, 2025
@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 23, 2025
Copy link

@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 database connection error, not directly due to the code changes in this PR. However, the changes introduce a dependency on the analytic_distribution field and the analytic.mixin, which may not be properly initialized or available in the test environment, especially in a minimal or isolated setup (e.g., runboat).

2. Suggested Fix

Ensure that the analytic.mixin is correctly inherited and that the analytic_distribution field is properly initialized in the SaleSubscriptionLine model. Specifically:

  • In sale_subscription_line.py, verify that the _inherit = "analytic.mixin" line is correctly placed before any field definitions that depend on it.
  • Ensure the analytic_distribution field is properly declared or inherited from analytic.mixin.
  • In sale_order_line.py, make sure analytic_distribution is correctly passed to get_subscription_line_values().

File: subscription_oca/models/sale_subscription_line.py
Line: 9
Fix: Confirm that _inherit = "analytic.mixin" is placed correctly and does not interfere with field definition order.

3. Additional Code Issues

  • Missing field definition in SaleSubscriptionLine: The analytic_distribution field is expected to be provided by analytic.mixin, but if the mixin is not properly loaded or not present in the Odoo environment, it could cause runtime errors. Ensure analytic.mixin is always available or fallback gracefully.

4. Test Improvements

Add tests to ensure:

  • The analytic_distribution field is correctly propagated from SaleSubscriptionLine to SaleOrderLine and AccountMoveLine.
  • The analytic_distribution field is visible in the view only when analytic.group_analytic_accounting is granted.
  • The analytic_distribution is correctly computed and saved in both sale.order.line and account.move.line during subscription line creation.

Test Case Pattern (OCA):
Use TransactionCase or SavepointCase to test:

def test_analytic_distribution_inheritance(self):
    # Create a subscription line with analytic distribution
    # Check that it's correctly passed to sale order line
    # Check that it's correctly passed to account move line

Tags to use:

@tagged('post_install', 'manual_install')

This ensures proper testing of inheritance and field propagation in a realistic Odoo environment.


⚠️ PR Aging Alert: CRITICAL

This PR by @eLBati has been waiting for 369 days — that is over 12 months without being merged or closed.
💤 No activity for 112 days. Has this PR been forgotten?

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

@marcos-mendez
Copy link

BOT now working as it should. Gonna open an Issue to fix it thanks for beeing patiente with my work

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.

8 participants