Skip to content

[16.0][BKP] sale_saleor: Backport from 18.0#1152

Open
Kimkhoi3010 wants to merge 11 commits intoOCA:16.0from
Kimkhoi3010:backport-sale_saleor-18.0-to-16.0
Open

[16.0][BKP] sale_saleor: Backport from 18.0#1152
Kimkhoi3010 wants to merge 11 commits intoOCA:16.0from
Kimkhoi3010:backport-sale_saleor-18.0-to-16.0

Conversation

@Kimkhoi3010
Copy link

@Kimkhoi3010 Kimkhoi3010 commented Jan 14, 2026

Depend on:

  • https://github.com/OCA/e-commerce/pull/1148
  • https://github.com/OCA/e-commerce/pull/1153
@Kimkhoi3010 Kimkhoi3010 marked this pull request as draft January 14, 2026 10:46
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch 6 times, most recently from 906d8ed to c6d957a Compare January 16, 2026 04:41
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch 5 times, most recently from 1a3d8b3 to 95de7a8 Compare February 3, 2026 10:40
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch from 95de7a8 to 037c702 Compare February 5, 2026 11:16
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch from 037c702 to dc04c67 Compare February 25, 2026 05:27
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch 3 times, most recently from 3189c25 to 0aea9dd Compare February 25, 2026 08:55
@Kimkhoi3010 Kimkhoi3010 force-pushed the backport-sale_saleor-18.0-to-16.0 branch from 0aea9dd to 46d7410 Compare February 25, 2026 08:56
@Kimkhoi3010 Kimkhoi3010 marked this pull request as ready for review February 25, 2026 09:02
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 of the test failure

The test failure is caused by a database connection error during the Odoo startup process (Connection to the database failed). This is not a code logic issue in the sale_saleor module itself, but rather an infrastructure or environment issue in the test runner (likely Runboat) that prevents the database from being accessible.

2. Suggested fix

There is no code-level fix required for this error. The error occurs before any module code is executed, indicating an issue in the test environment setup (e.g., missing database, incorrect connection config, or transient infrastructure problem). Ensure that the test environment has a working PostgreSQL instance and that the Odoo configuration (odoo.conf) is correctly set up with valid database credentials.

3. Additional code issues

⚠️ Missing saleor_account_id in saleor.webhook.activation model

In controllers/saleor_webhook.py, the function _saleor_is_webhook_active searches for records using saleor_account_id, but this field may not exist on the saleor.webhook.activation model, or it may not be properly defined.

File: models/saleor_webhook_activation.py (not shown in diff but referenced in code)
Issue: If saleor_account_id is not a proper Many2one field, this will raise a FieldError or AttributeError during runtime.

⚠️ Potential AttributeError in _saleor_basic_order_vals

In _saleor_basic_order_vals, the code checks hasattr(so, "saleor_mark_as_paid") but does not verify that so is a valid sale.order record, nor does it ensure saleor_mark_as_paid is a defined field.

File: controllers/saleor_webhook.py, line ~570
Issue: If so is not a sale.order or the field doesn't exist, this could silently fail or cause unexpected behavior.

⚠️ Incomplete fallback in _saleor_parse_order_payment_details

In _saleor_parse_order_payment_details, if the API call fails, the fallback logic does not update status or number if they were not found in the payload. This could result in incomplete or missing payment details.

File: controllers/saleor_webhook.py, line ~540
Issue: The fallback logic does not ensure that status and number are always populated, even if the API fails.

4. Test improvements

Add TransactionCase for webhook controllers

Use TransactionCase to test webhook endpoints and ensure that:

  • Webhook signatures are validated correctly.
  • Account matching logic works with various header formats (Saleor-Domain, X-Saleor-Domain, etc.).
  • Payload parsing works with different data structures (dict, list).

Test _saleor_is_webhook_active with active/inactive webhooks

Create a test that verifies the behavior of _saleor_is_webhook_active when:

  • A webhook is active.
  • A webhook is inactive.
  • No matching webhook exists.

Test payment parsing and fallback logic

Add a SavepointCase to simulate API failures and test that fallback logic in _saleor_parse_order_payment_details correctly populates status and number.

Test hasattr checks in payment-related methods

Ensure that fields like saleor_mark_as_paid, saleor_status, etc., are tested for existence in sale.order models to prevent silent failures.


Note: The current diff only shows controller code and manifest. The full test suite should include tests for:

  • Model logic in models/
  • Webhook controller logic
  • Integration between Saleor and Odoo data flows
  • Proper handling of edge cases like missing or malformed data

Use OCA's TransactionCase and SavepointCase patterns for testing complex logic involving database changes and external API calls.


⏰ This PR has been open for 60 days.
🔍 No human reviews yet after 60 days. PSC members: a quick review would help keep this contributor engaged with OCA.

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

None yet

2 participants