From 409d1f0edfc9a5c658ef2c1776b8062fb594bf90 Mon Sep 17 00:00:00 2001 From: Manuela Cepeda Date: Wed, 5 Aug 2026 17:39:45 +0000 Subject: [PATCH 1/2] [FIX] purchase_ux: use a per document type criterion in purchase matching The previous fix switched the purchase matching filter to qty_to_invoice for both bills and credit notes. That works for credit notes but breaks bills: on products controlled on received quantities, qty_to_invoice is qty_received - qty_invoiced, so a confirmed purchase order with no receipt yet gives 0 and every line was hidden from the matcher. Use the criterion that fits each document type instead: * in_invoice: product_qty > qty_invoiced, ie. ordered quantity not billed yet, received or not. * in_refund: qty_to_invoice < 0, ie. the pending credit left by a return on a line that is already fully billed. closes ingadhoc/purchase#353 Signed-off-by: Juan Carreras --- purchase_ux/models/account_move.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/purchase_ux/models/account_move.py b/purchase_ux/models/account_move.py index 8d1fcfb7..bee16bd5 100644 --- a/purchase_ux/models/account_move.py +++ b/purchase_ux/models/account_move.py @@ -93,12 +93,14 @@ def action_purchase_matching(self): ctx["purchase_matching_from_button"] = True ctx["default_account_move_id"] = self.id res["context"] = ctx - # Show POLs with a pending amount to invoice, using qty_to_invoice so that - # returns are handled: on a bill (in_invoice) we want lines still to bill - # (qty_to_invoice > 0), on a credit note (in_refund) we want lines with a - # pending refund left by a return (qty_to_invoice < 0). The previous check - # (product_qty > qty_invoiced) ignored returns, since product_qty does not - # drop with a return, and hid those lines from the matcher. + # Show POLs with something pending, with a different criterion per document type: + # * on a bill (in_invoice): ordered qty not billed yet (product_qty > qty_invoiced), + # received or not. qty_to_invoice cannot be used here because on products + # controlled on received quantities it is qty_received - qty_invoiced, so a + # confirmed PO with no receipt yet gives 0 and the line would be hidden. + # * on a credit note (in_refund): lines left with a pending refund by a return, + # ie. billed more than received (qty_to_invoice < 0). product_qty cannot be used + # here because it does not drop with a return, so a fully billed line gives 0. all_pols = self.env["purchase.order.line"].search( [ ("partner_id", "in", (self.partner_id | self.partner_id.commercial_partner_id).ids), @@ -113,8 +115,9 @@ def action_purchase_matching(self): def _pending(pol): if pol.id in already_matched: return False - sign = float_compare(pol.qty_to_invoice, 0.0, precision_digits=uom_precision) - return sign < 0 if is_refund else sign > 0 + if is_refund: + return float_compare(pol.qty_to_invoice, 0.0, precision_digits=uom_precision) < 0 + return float_compare(pol.product_qty, pol.qty_invoiced, precision_digits=uom_precision) > 0 pending_pol_ids = all_pols.filtered(_pending).ids domain = list(res.get("domain") or []) From 835f12e22a3ec1f330d54fc3a7774c3547224b11 Mon Sep 17 00:00:00 2001 From: adhoc-cicd-bot Date: Mon, 10 Aug 2026 16:40:41 +0000 Subject: [PATCH 2/2] [UPD] copier: sync template 4c4a3ee --- .copier-answers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 41349916..88f08f64 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Do NOT update manually; changes here will be overwritten by Copier -_commit: 8677dea +_commit: 4c4a3ee _src_path: https://github.com/ingadhoc/addons-repo-template.git description: ADHOC Odoo purchase Modules is_private: false