Filter receivable lines by mandate company
The receivable-with-mandate tab must use the company of each move line, as payment processing does. A mandate of another company does not make the line collectible. Closes #15125
This commit is contained in:
@@ -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'
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">Receivable with Mandate</field>
|
||||
<field name="sequence" eval="25"/>
|
||||
<field name="domain"
|
||||
eval="['AND', ('account.type.receivable', '=', True), ['OR', ('debit', '>', 0), ('credit', '<', 0)], ('party.sepa_mandates.state', '=', 'validated')]"
|
||||
eval="['AND', ('account.type.receivable', '=', True), ['OR', ('debit', '>', 0), ('credit', '<', 0)], ('sepa_mandate_available', '=', True)]"
|
||||
pyson="1"/>
|
||||
<field name="count" eval="True"/>
|
||||
<field name="act_window" ref="account_payment.act_move_line_form"/>
|
||||
|
||||
@@ -28,6 +28,7 @@ model:
|
||||
party.PartyIdentifier
|
||||
account.Configuration
|
||||
account.ConfigurationSepaMandateSequence
|
||||
account.MoveLine
|
||||
wizard:
|
||||
party.Replace
|
||||
report:
|
||||
|
||||
Reference in New Issue
Block a user