details: https://code.tryton.org/tryton/commit/c867f00cd0a0
branch: 7.8
user: Cédric Krier <[email protected]>
date: Fri Jan 23 18:50:42 2026 +0100
description:
Search for similar invoice line with the same category of unit for UBL
invoice line
Closes #14548
(grafted from 9a68fc0961be8a743ea5b2c2833b1623bc210e11)
diffstat:
modules/edocument_ubl/edocument.py | 38 ++++++++++++++++++++++++--------------
1 files changed, 24 insertions(+), 14 deletions(-)
diffs (55 lines):
diff -r 802f5bcb434c -r c867f00cd0a0 modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py Fri Jan 23 15:29:07 2026 +0100
+++ b/modules/edocument_ubl/edocument.py Fri Jan 23 18:50:42 2026 +0100
@@ -389,13 +389,18 @@
if not line.product:
if line.description:
- similar_lines = Line.search([
- ('description', 'ilike', line.description),
- ('invoice.company', '=', company),
- ('invoice.type', '=', 'in'),
- ('invoice.state', 'in',
- ['validated', 'posted', 'paid']),
- ],
+ similar_domain = [
+ ('description', 'ilike', line.description),
+ ('invoice.company', '=', company),
+ ('invoice.type', '=', 'in'),
+ ('invoice.state', 'in',
+ ['validated', 'posted', 'paid']),
+ ]
+ if line.unit:
+ similar_domain.append(
+ ('unit.category', '=', line.unit.category))
+ similar_lines = Line.search(
+ similar_domain,
order=[('invoice.invoice_date', 'DESC')],
limit=1)
else:
@@ -565,13 +570,18 @@
if not line.product:
if line.description:
- similar_lines = Line.search([
- ('description', 'ilike', line.description),
- ('invoice.company', '=', company),
- ('invoice.type', '=', 'in'),
- ('invoice.state', 'in',
- ['validated', 'posted', 'paid']),
- ],
+ similar_domain = [
+ ('description', 'ilike', line.description),
+ ('invoice.company', '=', company),
+ ('invoice.type', '=', 'in'),
+ ('invoice.state', 'in',
+ ['validated', 'posted', 'paid']),
+ ]
+ if line.unit:
+ similar_domain.append(
+ ('unit.category', '=', line.unit.category))
+ similar_lines = Line.search(
+ similar_domain,
order=[('invoice.invoice_date', 'DESC')],
limit=1)
else: