-
Notifications
You must be signed in to change notification settings - Fork 30.2k
[FIX] purchase: match only invoice lines in matching process #197637
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
[FIX] purchase: match only invoice lines in matching process #197637
Conversation
|
Hello, Would it be possible to have this PR reviewed promptly? It is currently blocking the loading of certain IT bills for our clients. Thank you! |
|
@svs-odoo Hello, could I get an update? Thanks 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @LouisGobert
Thanks for the fix, it looks good to me !
I let you two small comments about the test
07339a2 to
180cd65
Compare
|
@LouisGobert rebase your branch please |
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
180cd65 to
3626b1c
Compare
|
Done :) |
|
robodoo r+ |
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 #197637 Signed-off-by: Steve Van Essche <svs@odoo.com>
|
@LouisGobert @svs-odoo staging failed: ci/runbot on 2253a49e627daa156f9f872e1f0b6796c6539a9e (view more at https://runbot.odoo.com/runbot/build/77376053) |
|
@robodoo retry |
|
@LouisGobert @svs-odoo staging failed: ci/runbot on 90ac32c0942e36c52b83b192a0288ab206ebac83 (view more at https://runbot.odoo.com/runbot/build/77383662) |
|
@robodoo retry |
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 #197637 Signed-off-by: Steve Van Essche <svs@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