Skip to content

[16.0][IMP] subscription_oca: improve config UX and duplication#1319

Open
Mohajiro wants to merge 1 commit intoOCA:16.0from
cetmix:16.0-t5020-suscription_oca-modification
Open

[16.0][IMP] subscription_oca: improve config UX and duplication#1319
Mohajiro wants to merge 1 commit intoOCA:16.0from
cetmix:16.0-t5020-suscription_oca-modification

Conversation

@Mohajiro
Copy link

Add '(copy)' suffix on duplication and sequence handles for stages, templates, tags, and close reasons.
Enable tree,form views and remove inline editing.

Task: 5020

@Mohajiro Mohajiro force-pushed the 16.0-t5020-suscription_oca-modification branch from b88158f to 4ee0743 Compare October 22, 2025 07:26
Add '(copy)' suffix on duplication and sequence handles
for stages, templates, tags, and close reasons.
Enable tree,form views and remove inline editing.

Task: 5020
@Mohajiro Mohajiro force-pushed the 16.0-t5020-suscription_oca-modification branch from 4c26395 to a649ab2 Compare October 24, 2025 14:20
@ivs-cetmix
Copy link
Member

Hi @carlos-domatix we made some UI/UX enhancements of your beautiful module, would appreciate your review!

@github-actions
Copy link

github-actions bot commented Mar 1, 2026

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 Mar 1, 2026
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 occurs in setUpClass of TestSubscriptionOCA when trying to search for a journal using cls.env["account.journal"].search([]) which returns an empty recordset, leading to an IndexError: tuple index out of range when accessing cls.cash_journal[0].

2. Suggested Fix

In subscription_oca/tests/test_subscription_oca.py, line 29, replace:

cls.cash_journal = cls.env["account.journal"].search([])

with:

cls.cash_journal = cls.env["account.journal"].search([("type", "=", "cash")], limit=1)

or ensure that at least one cash journal exists in the test environment before this line.

3. Additional Code Issues

  • Missing field definitions in inherited models: The models sale_subscription_close_reason, sale_subscription_stage, sale_subscription_tag, and sale_subscription_template inherit from subscription.generic.field.mixin but do not explicitly define the name and sequence fields (they are inherited). While this works, it's not immediately clear from the model definition that these fields exist unless you know the mixin. It's better to document or explicitly show field usage in the models if not using fields.* imports directly.

  • Mixin _order field: The mixin defines _order = "sequence, name" which applies to all inheriting models. This is fine, but if any of the inheriting models have custom ordering requirements or need to override this, it should be documented or handled carefully.

4. Test Improvements

Add a TransactionCase or SavepointCase test to validate that the mixin works correctly across different models:

def test_generic_field_mixin_inheritance(self):
    # Test that all models using the mixin have expected fields and behavior
    model_names = [
        "sale.subscription.close.reason",
        "sale.subscription.stage",
        "sale.subscription.tag",
        "sale.subscription.template"
    ]
    for model_name in model_names:
        model = self.env[model_name]
        self.assertTrue(hasattr(model, 'name'))
        self.assertTrue(hasattr(model, 'sequence'))

Also, improve the existing test for copy behavior by adding edge cases:

def test_subscription_generic_field_mixin_copy_edge_cases(self):
    TestModel = self.env["sale.subscription.template"]
    original = TestModel.create({"name": "Test Template", "code": "test"})
    
    # Test copy with empty name
    original.name = ""
    copied = original.copy()
    self.assertEqual(copied.name, "(copy)")

    # Test copy with None name
    original.name = None
    copied = original.copy()
    self.assertEqual(copied.name, "(copy)")

Use SavepointCase for tests involving model creation and copying to ensure clean state isolation between tests.


⏰ PR Aging Alert

This PR by @Mohajiro has been open for 144 days (4 months).
🔴 Zero human reviews in 144 days. This contributor invested their time to improve this module. The PSC owes them at least a response — even a "needs changes" is better than silence.

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

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

Labels

stale PR/Issue without recent activity, it'll be soon closed automatically.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants