Skip to content

[IMP] purchase_ux: exclude force-invoiced POs from purchase matching view#335

Open
feg-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-t-66624-feg
Open

[IMP] purchase_ux: exclude force-invoiced POs from purchase matching view#335
feg-adhoc wants to merge 1 commit into
ingadhoc:19.0from
adhoc-dev:19.0-t-66624-feg

Conversation

@feg-adhoc

Copy link
Copy Markdown

Summary

When a purchase order has force_invoiced_status = 'invoiced' (manually forced as fully invoiced via the button_set_invoiced mechanism in purchase_ux), its lines were still appearing in the Asociar lineas de compra smart button on vendor bills.

This happened because purchase.bill.line.match is a SQL view built from _select_po_line(), which filters by qty_to_invoice != 0 and product_qty > qty_invoiced — raw DB columns that are not updated when force_invoiced_status is set (only qty_to_invoice is zeroed out via button_set_invoiced, but force_invoiced_status is a separate field for the non-destructive force path).

Change

Override _select_po_line() in purchase_ux's PurchaseBillLineMatch to wrap the parent query and exclude any purchase order where force_invoiced_status = 'invoiced'.

Test plan

  1. Confirm a purchase order and set it as force-invoiced (force_invoiced_status = 'invoiced').
  2. Open a draft vendor bill for the same partner.
  3. Click the Asociar lineas de compra smart button.
  4. Verify the force-invoiced PO lines do not appear in the matching view.
  5. Verify that PO lines from normal (non-force-invoiced) orders still appear as expected.

Copilot AI review requested due to automatic review settings June 11, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SQL from odoo.tools to compose a parametrized SQL fragment.
  • Override _select_po_line() to wrap the parent query and apply an additional filter on purchase_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'
)
@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants