Skip to content

[ADD] helpdesk_mgmt_stock_sale_origin: Pre-fill sale order field on helpdesk ticket created from an outgoing picking#969

Open
nicolas-delbovier-acsone wants to merge 2 commits intoOCA:16.0from
acsone:16.0-add-helpdesk_mgmt_stock_sale_origin
Open

[ADD] helpdesk_mgmt_stock_sale_origin: Pre-fill sale order field on helpdesk ticket created from an outgoing picking#969
nicolas-delbovier-acsone wants to merge 2 commits intoOCA:16.0from
acsone:16.0-add-helpdesk_mgmt_stock_sale_origin

Conversation

@nicolas-delbovier-acsone

Depends on #875

…elpdesk ticket created from an outgoing picking
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 (Connection to the database failed) during the Odoo startup, which prevents the test suite from running. This is likely due to misconfiguration or an invalid database URL in the test environment setup.

2. Suggested Fix

Ensure the database connection parameters in the test environment are correctly configured. Specifically, verify that:

  • The database parameter in the Odoo configuration file or environment variables points to a valid, accessible PostgreSQL instance.
  • The db_user and db_password are correctly set if authentication is required.
  • The test-requirements.txt does not introduce conflicting dependencies or incorrect references (e.g., odoo-addon-helpdesk-mgmt-stock @ git+https://github.com/OCA/helpdesk.git@refs/pull/875/head#subdirectory=setup/helpdesk_mgmt_stock may be unstable or invalid).

3. Additional Code Issues

  • In stock_picking.py: The search_read call is inefficient and potentially redundant. It can be simplified to a direct search if only the id is needed:

    origin_so = self.env["sale.order"].search([("name", "=", self.origin)], limit=1)
    if origin_so:
        action["context"].update({
            "default_sale_order_ids": [Command.set([origin_so.id])]
        })

    This avoids fetching unnecessary data and improves performance.

  • In test_helpdesk_mgmt_stock_sale_origin.py: The test uses Command.set() which is correct, but it's better to ensure that self.so is properly initialized with a name field that matches self.origin. Currently, sale.order's name field is auto-generated (e.g., SO001), so self.origin in the picking may not match self.so.name. This could cause the test to fail.

4. Test Improvements

To improve test coverage and robustness, add the following test cases:

  • Test with no matching sale order: Ensure action["context"] is not modified when self.origin does not match any sale order.
  • Test with self.origin being None or empty: Ensure no error occurs in such edge cases.
  • Test with multiple sale orders having the same name: Ensure only one is picked (or behavior is well-defined).
  • Use SavepointCase for more complex scenarios where data isolation is required, as per OCA patterns.

Example:

def test_action_view_helpdesk_tickets_no_origin(self):
    # Test with no origin
    self.out_pick.origin = False
    action = self.out_pick.action_view_helpdesk_tickets()
    self.assertNotIn("default_sale_order_ids", action["context"])

def test_action_view_helpdesk_tickets_no_matching_so(self):
    # Test with non-matching origin
    self.out_pick.origin = "NONEXISTENT"
    action = self.out_pick.action_view_helpdesk_tickets()
    self.assertNotIn("default_sale_order_ids", action["context"])

These tests ensure that the logic handles edge cases gracefully and matches OCA's testing standards.


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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants