[IMP] purchase_ux: exclude force-invoiced POs from purchase matching view#335
Open
feg-adhoc wants to merge 1 commit into
Open
[IMP] purchase_ux: exclude force-invoiced POs from purchase matching view#335feg-adhoc wants to merge 1 commit into
feg-adhoc wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds an override to the PO line selection query to exclude lines belonging to purchase orders with force_invoiced_status = 'invoiced'.
Changes:
- Import
SQLfromodoo.toolsto compose a parametrized SQL fragment. - Override
_select_po_line()to wrap the parent query and apply an additional filter onpurchase_order_id.
Comment on lines
+42
to
+52
| @api.model | ||
| def _select_po_line(self): | ||
| return SQL( | ||
| """ | ||
| SELECT subquery.* FROM (%s) AS subquery | ||
| WHERE subquery.purchase_order_id NOT IN ( | ||
| SELECT id FROM purchase_order WHERE force_invoiced_status = 'invoiced' | ||
| ) | ||
| """, | ||
| super()._select_po_line(), | ||
| ) |
Comment on lines
+46
to
+49
| SELECT subquery.* FROM (%s) AS subquery | ||
| WHERE subquery.purchase_order_id NOT IN ( | ||
| SELECT id FROM purchase_order WHERE force_invoiced_status = 'invoiced' | ||
| ) |
Contributor
…view When a purchase order has force_invoiced_status = 'invoiced' (manually forced as 'Totalmente facturado'), its lines were still appearing in the 'Asociar lineas de compra' smart button because the underlying SQL view did not consider that field. Override _select_po_line() to filter out purchase orders with force_invoiced_status = 'invoiced' from purchase.bill.line.match.
419be80 to
f90f1db
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
When a purchase order has
force_invoiced_status = 'invoiced'(manually forced as fully invoiced via thebutton_set_invoicedmechanism inpurchase_ux), its lines were still appearing in the Asociar lineas de compra smart button on vendor bills.This happened because
purchase.bill.line.matchis a SQL view built from_select_po_line(), which filters byqty_to_invoice != 0andproduct_qty > qty_invoiced— raw DB columns that are not updated whenforce_invoiced_statusis set (onlyqty_to_invoiceis zeroed out viabutton_set_invoiced, butforce_invoiced_statusis a separate field for the non-destructive force path).Change
Override
_select_po_line()inpurchase_ux'sPurchaseBillLineMatchto wrap the parent query and exclude any purchase order whereforce_invoiced_status = 'invoiced'.Test plan
force_invoiced_status = 'invoiced').