-
Notifications
You must be signed in to change notification settings - Fork 30.2k
[FW][FIX] purchase: match only invoice lines in matching process #204022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FW][FIX] purchase: match only invoice lines in matching process #204022
Conversation
|
This PR targets saas-18.1 and is part of the forward-port chain. Further PRs will be created up to master. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
|
@LouisGobert @svs-odoo ci/runbot failed on this forward-port PR |
Currently, an error can occur in `_find_matching_po_and_inv_lines` when some invoice lines have a price_unit of 0. This happens because the matching logic sorts and matches lines by `(price_unit, qty)`, leading to "Journal Items" (`line_ids`) being incorrectly matched with purchase order lines. The issue arises because the `_find_matching_po_and_inv_lines` function checks all `line_ids`, instead of only `invoice_line_ids`. When a PO line has a price_unit of 0, it might match with a line that isn't an actual invoice line. As a result, `unmatched_lines` becomes incorrect, and it could remove a valid invoice line. Then, later, when calculating `inv_and_po_lines`, the process only considers `invoice_line_ids`. Since no matching line is found, an error occurs when attempting to delete the line (id is False). Steps to reproduce: 1. Create a purchase order with: - 1 product A with price_unit = 0 2. Confirm the purchase order. 3. Upload an EDI XML bill (e.g., IT localization) with: - A reference to the purchase order - 1 product B with price_unit = 100 Since all bill lines are processed, a tax line or a payment term line might incorrectly match with the PO line, causing the error. opw-4513869 X-original-commit: f9cc651
1b4f349 to
6b70feb
Compare
|
@LouisGobert @svs-odoo this PR was modified / updated and has become a normal PR. It must be merged directly. |
|
@robodoo r+ |
|
@LouisGobert @svs-odoo 'ci/runbot' failed on this reviewed PR. |
Currently, an error can occur in `_find_matching_po_and_inv_lines` when some invoice lines have a price_unit of 0. This happens because the matching logic sorts and matches lines by `(price_unit, qty)`, leading to "Journal Items" (`line_ids`) being incorrectly matched with purchase order lines. The issue arises because the `_find_matching_po_and_inv_lines` function checks all `line_ids`, instead of only `invoice_line_ids`. When a PO line has a price_unit of 0, it might match with a line that isn't an actual invoice line. As a result, `unmatched_lines` becomes incorrect, and it could remove a valid invoice line. Then, later, when calculating `inv_and_po_lines`, the process only considers `invoice_line_ids`. Since no matching line is found, an error occurs when attempting to delete the line (id is False). Steps to reproduce: 1. Create a purchase order with: - 1 product A with price_unit = 0 2. Confirm the purchase order. 3. Upload an EDI XML bill (e.g., IT localization) with: - A reference to the purchase order - 1 product B with price_unit = 100 Since all bill lines are processed, a tax line or a payment term line might incorrectly match with the PO line, causing the error. opw-4513869 closes #204022 X-original-commit: f9cc651 Signed-off-by: Steve Van Essche <svs@odoo.com> Signed-off-by: Louis Gobert (loug) <loug@odoo.com>

Currently, an error can occur in
_find_matching_po_and_inv_lineswhen some invoice lines have a price_unit of 0. This happens because the matching logic sorts and matches lines by(price_unit, qty), leading to "Journal Items" (line_ids) being incorrectly matched with purchase order lines.The issue arises because the
_find_matching_po_and_inv_linesfunction checks allline_ids, instead of onlyinvoice_line_ids. When a PO line has a price_unit of 0, it might match with a line that isn't an actual invoice line. As a result,unmatched_linesbecomes incorrect, and it could remove a valid invoice line. Then, later, when calculatinginv_and_po_lines, the process only considersinvoice_line_ids. Since no matching line is found, an error occurs when attempting to delete the line (id is False).Steps to reproduce:
Since all bill lines are processed, a tax line or a payment term line might incorrectly match with the PO line, causing the error.
opw-4513869
Forward-Port-Of: #197637