[16.0][FIX] purchase_sale_stock_inter_company - #888
Conversation
371c816 to
53efb09
Compare
…fig from picking_type in intercompany flow
f21e259 to
03d255f
Compare
|
This PR has the |
|
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. |
marcos-mendez
left a comment
There was a problem hiding this comment.
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 server startup, which occurs before any code in the PR is executed. This is not due to the changes in stock_picking.py, but likely due to misconfiguration or environment issues in the test runner (e.g., runboat).
2. Suggested Fix
There is no code fix needed for the PR itself, as the failure is unrelated to the changes. However, ensure that:
- The test environment (e.g.,
runboat) is properly configured with a valid database connection. - The database service is up and accessible.
- If this is a CI issue, verify that
odoo.confor environment variables are correctly set for the test DB.
3. Additional Code Issues
No real bugs found in the provided diff. The code change is valid:
button_validate()is the correct method to use instead of_action_done()for triggering validation with context.- Filtering out
doneandcancelstates is correct. - Context keys like
skip_backorder,skip_immediate, andbypass_set_number_of_packagesare valid and used in Odoo's stock flows.
4. Test Improvements
To better cover this logic, consider adding the following test cases in a TransactionCase or SavepointCase:
def test_intercompany_picking_done_with_pending_picks(self):
# Create intercompany purchase and sale orders
# Create a stock picking for the purchase order
# Ensure that the related sale picking is validated with correct context
# Assert that the sale picking is in 'done' stateUse @tagged('post_install', 'standard') to mark tests that require inter-company setup.
Also, test edge cases like:
- When
po_pickscontains a mix ofdoneanddraftpickings. - When
po_pick.company_idis different from the current company.
These tests should be added to test/stock_picking.py or a new test file under purchase_sale_stock_inter_company/tests/.
✅ Summary: No functional bugs in the code change. The test failure is environment-related and unrelated to the PR.
⏰ PR Aging Alert
This PR by @AdrianaSaiz has been open for 157 days (5 months).
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
Problem:
In intercompany scenarios with partial deliveries from different warehouses, automatic validation fails. For instance when Company A purchases 2 units from Company B, and Company B delivers via two separate 1-unit pickings:
First delivery validates correctly but remaining quantity gets cancelled instead of creating a backorder
Second delivery fails with "No corresponding line in PO" because the purchase order line was cancelled
Manual validation works correctly, but automatic validation doesn't respect backorder configuration
Root Cause:
The _set_intercompany_picking_qty() method returns all pickings related to the purchase order, including already completed pickings from previous partial deliveries. When processing backorders, the system attempts to validate these completed pickings, causing validation failures.
Changes Made:
Changed from _action_done() to button_validate() to respect user backorder configuration instead of always canceling remaining quantities
Added picking state filtering: Filter out completed/cancelled pickings before validation to prevent attempts to validate already processed transfers
Impact:
Fixes intercompany partial deliveries with backorders
Respects user backorder settings (Create/Ask/Never)
Maintains backward compatibility for single deliveries