details:   https://code.tryton.org/tryton/commit/7b62424ca530
branch:    default
user:      Cédric Krier <[email protected]>
date:      Thu Jan 15 22:34:01 2026 +0100
description:
        Ensure that the unit price on the invoice line is not negative for 
Peppol

        Closes #14504
diffstat:

 modules/edocument_peppol/CHANGELOG     |   1 +
 modules/edocument_peppol/account.py    |  13 ++++++++++++-
 modules/edocument_peppol/exceptions.py |   6 +++++-
 modules/edocument_peppol/message.xml   |   3 +++
 4 files changed, 21 insertions(+), 2 deletions(-)

diffs (75 lines):

diff -r 06e183433933 -r 7b62424ca530 modules/edocument_peppol/CHANGELOG
--- a/modules/edocument_peppol/CHANGELOG        Fri Jan 16 16:56:47 2026 +0100
+++ b/modules/edocument_peppol/CHANGELOG        Thu Jan 15 22:34:01 2026 +0100
@@ -1,3 +1,4 @@
+* Ensure that the unit price on the invoice line is not negative
 * Add an "Update Status" button to the Peppol document
 
 Version 7.8.0 - 2025-12-15
diff -r 06e183433933 -r 7b62424ca530 modules/edocument_peppol/account.py
--- a/modules/edocument_peppol/account.py       Fri Jan 16 16:56:47 2026 +0100
+++ b/modules/edocument_peppol/account.py       Thu Jan 15 22:34:01 2026 +0100
@@ -6,7 +6,7 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval
 
-from .exceptions import InvoicePeppolRequired
+from .exceptions import InvoicePeppolError, InvoicePeppolRequired
 
 
 class Invoice(metaclass=PoolMeta):
@@ -47,6 +47,7 @@
             peppol_types = invoice.party.get_multivalue(
                 'peppol_types', company=invoice.company.id)
             if peppol_types and 'bis-billing-3' in peppol_types:
+                invoice.check_peppol()
                 peppol.append(Peppol(
                         direction='out',
                         company=invoice.company,
@@ -65,3 +66,13 @@
         if peppol:
             Peppol.save(peppol)
             Peppol.submit(peppol)
+
+    def check_peppol(self):
+        "Check if the invoice is valid for Peppol"
+        for line in self.lines:
+            if line.type == 'line' and line.unit_price < 0:  # BR-27
+                raise InvoicePeppolError(gettext(
+                        'edocument_peppol.'
+                        'msg_invoice_line_unit_price_not_negative',
+                        invoice=self.rec_name,
+                        line=line.rec_name))
diff -r 06e183433933 -r 7b62424ca530 modules/edocument_peppol/exceptions.py
--- a/modules/edocument_peppol/exceptions.py    Fri Jan 16 16:56:47 2026 +0100
+++ b/modules/edocument_peppol/exceptions.py    Thu Jan 15 22:34:01 2026 +0100
@@ -1,12 +1,16 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
-from trytond.exceptions import UserWarning
+from trytond.exceptions import UserError, UserWarning
 
 
 class InvoicePeppolRequired(UserWarning):
     pass
 
 
+class InvoicePeppolError(UserError):
+    pass
+
+
 class PeppolServiceError(Exception):
     pass
diff -r 06e183433933 -r 7b62424ca530 modules/edocument_peppol/message.xml
--- a/modules/edocument_peppol/message.xml      Fri Jan 16 16:56:47 2026 +0100
+++ b/modules/edocument_peppol/message.xml      Thu Jan 15 22:34:01 2026 +0100
@@ -9,5 +9,8 @@
         <record model="ir.message" id="msg_invoice_party_peppol_required">
             <field name="text">The party "%(party)s" is not set up to send the 
invoice "%(invoice)s" via the Peppol network.</field>
         </record>
+        <record model="ir.message" 
id="msg_invoice_line_unit_price_not_negative">
+            <field name="text">In order to post the invoice "%(invoice)s" on 
the Peppol network, the unit price of the line "%(line)s" must not be 
negative.</field>
+        </record>
     </data>
 </tryton>

Reply via email to