Ensure that the unit price on the invoice line is not negative for Peppol

Closes #14504
This commit is contained in:
Cédric Krier
2026-01-15 22:34:01 +01:00
parent b0ff152120
commit f38652ef03
4 changed files with 21 additions and 2 deletions
+1
View File
@@ -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
+12 -1
View File
@@ -6,7 +6,7 @@ from trytond.model import fields
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 @@ class Invoice(metaclass=PoolMeta):
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 @@ class Invoice(metaclass=PoolMeta):
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))
+5 -1
View File
@@ -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
+3
View File
@@ -9,5 +9,8 @@ this repository contains the full copyright notices and license terms. -->
<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>