diff --git a/modules/account_payment_sepa/account.py b/modules/account_payment_sepa/account.py
index f24a966482..f75c745f67 100644
--- a/modules/account_payment_sepa/account.py
+++ b/modules/account_payment_sepa/account.py
@@ -1,6 +1,9 @@
# 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 sql import Literal
+from sql.operators import Exists
+
from trytond.i18n import gettext
from trytond.model import ModelSQL, fields
from trytond.modules.company.model import CompanyValueMixin
@@ -31,6 +34,33 @@ class ConfigurationSepaMandateSequence(ModelSQL, CompanyValueMixin):
])
+class MoveLine(metaclass=PoolMeta):
+ __name__ = 'account.move.line'
+
+ sepa_mandate_available = fields.Function(fields.Boolean(
+ "SEPA Mandate Available"))
+
+ @classmethod
+ def column_sepa_mandate_available(cls, tables):
+ pool = Pool()
+ Move = pool.get('account.move')
+ Mandate = pool.get('account.payment.sepa.mandate')
+ line, _ = tables[None]
+ move_tables = tables.get('move')
+ if move_tables is None:
+ move = Move.__table__()
+ tables['move'] = {
+ None: (move, move.id == line.move),
+ }
+ else:
+ move, _ = move_tables[None]
+ mandate = Mandate.__table__()
+ return Exists(mandate.select(Literal(1),
+ where=(mandate.party == line.party)
+ & (mandate.company == move.company)
+ & (mandate.state == 'validated')))
+
+
class InvoicePaymentMean(metaclass=PoolMeta):
__name__ = 'account.invoice.payment.mean'
diff --git a/modules/account_payment_sepa/account.xml b/modules/account_payment_sepa/account.xml
index fe40ac5567..39de307a72 100644
--- a/modules/account_payment_sepa/account.xml
+++ b/modules/account_payment_sepa/account.xml
@@ -9,7 +9,7 @@ this repository contains the full copyright notices and license terms. -->
Receivable with Mandate
diff --git a/modules/account_payment_sepa/tryton.cfg b/modules/account_payment_sepa/tryton.cfg
index 88e09a26b8..d34795a96a 100644
--- a/modules/account_payment_sepa/tryton.cfg
+++ b/modules/account_payment_sepa/tryton.cfg
@@ -28,6 +28,7 @@ model:
party.PartyIdentifier
account.Configuration
account.ConfigurationSepaMandateSequence
+ account.MoveLine
wizard:
party.Replace
report: