[16.0][BKP] sale_saleor: Backport from 18.0#1152
[16.0][BKP] sale_saleor: Backport from 18.0#1152Kimkhoi3010 wants to merge 11 commits intoOCA:16.0from
Conversation
906d8ed to c6d957a Compare 1a3d8b3 to 95de7a8 Compare 95de7a8 to 037c702 Compare 037c702 to dc04c67 Compare 3189c25 to 0aea9dd Compare 0aea9dd to 46d7410 Compare
marcos-mendez left a comment
There was a problem hiding this comment.
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:
- server-tools#3554 [MIG] datetime_formatter: Migration to 18.0
- server-tools#3548 [18.0][MIG] base_kanban_stage: Migration to 18.0
- hr-attendance#262 [16.0][ADD] Hr_attendance_idsecure: iDSecure (ControliD) attendance integration
- stock-logistics-workflow#2276 [16.0][ADD] stock_move_line_devaluation
- stock-logistics-workflow#2275 [16.0][ADD] Stock move line analytic account
- stock-logistics-workflow#2268 [16.0][ADD] stock_move_line_picking_partner
- purchase-workflow#2694 [16.0][IMP]Purchase workflow added to review state & exception fix
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
Depend on:
https://github.com/OCA/e-commerce/pull/1148https://github.com/OCA/e-commerce/pull/1153