Skip to content

[16.0] [IMP] mgmtsystem_evaluation: only manager should reset to draft#768

Open
luisDIXMIT wants to merge 1 commit into
OCA:16.0from
dixmit:16.0-imp-mgmtsytem_evaluation
Open

[16.0] [IMP] mgmtsystem_evaluation: only manager should reset to draft#768
luisDIXMIT wants to merge 1 commit into
OCA:16.0from
dixmit:16.0-imp-mgmtsytem_evaluation

Conversation

@luisDIXMIT
Copy link
Copy Markdown
Contributor

A normal user can perform all actions, but the only ones they should be allowed to do are initiating or canceling an evaluation.

Copy link
Copy Markdown
Member

@etobella etobella left a comment

Choose a reason for hiding this comment

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

Thanks

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 due to a database connection error, not directly related to the XML change. However, the change introduces a new groups attribute on a button in mgmtsystem_evaluation.xml, which may cause access control issues if the group mgmtsystem.group_mgmtsystem_manager is not properly defined or loaded during the test run.


2. Suggested Fix

Ensure that the group mgmtsystem.group_mgmtsystem_manager exists and is correctly loaded before the test runs. If the group is defined in the module, confirm it's included in the manifest (__manifest__.py) under data or demo files. If it's missing, add it to the module's data files or verify that it's inherited from another module.

If the group is not defined in this module, and the test fails because of missing access rights, you should either:

  • Add the group definition to data/group.xml, or
  • Update the test to ensure the required group is available.

File to check/update: __manifest__.py, data/group.xml (if exists), or test setup.


3. Additional Code Issues

  • No functional issues in the diff itself — the addition of groups="mgmtsystem.group_mgmtsystem_manager" is valid Odoo syntax and does not introduce bugs.
  • However, the test environment may not be fully initialized, causing the connection failure. This is likely a test setup issue, not a code issue.

4. Test Improvements

Add a test case that ensures the button is only visible to users with the mgmtsystem.group_mgmtsystem_manager group. Use SavepointCase or TransactionCase to test visibility and access control.

Suggested test:

def test_button_visibility(self):
    # Create a user without the manager group
    user = self.env['res.users'].create({
        'name': 'Test User',
        'login': 'testuser@example.com',
        'groups_id': [(6, 0, [self.env.ref('base.group_user').id])]
    })

    # Create an evaluation record
    evaluation = self.env['mgmtsystem.evaluation'].create({
        'name': 'Test Evaluation',
        'state': 'done',
    })

    # Check that button is invisible to non-manager user
    view = evaluation.with_user(user).fields_view_get(view_type='form')
    button_visible = 'Back to draft' in view['arch']
    self.assertFalse(button_visible)

Reference OCA patterns:

  • Use SavepointCase for tests that involve access rights and groups.
  • Use TransactionCase for more complex data setups.

Conclusion: The XML change is valid. The test failure is likely due to a missing group or misconfigured test environment, not a code bug. Ensure mgmtsystem.group_mgmtsystem_manager is available in the test context.


⏰ This PR has been open for 32 days.
💤 Last activity was 32 days ago.

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

@max3903 max3903 added this to the 16.0 milestone May 2, 2026
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.

4 participants