File: account_payment.py

package info (click to toggle)
tryton-modules-account-es 7.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,392 kB
  • sloc: xml: 27,540; python: 1,290; makefile: 11; sh: 3
file content (35 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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.model import fields
from trytond.pool import PoolMeta
from trytond.pyson import Eval


class Journal(metaclass=PoolMeta):
    __name__ = 'account.payment.journal'
    es_sepa_bank_account_country_code = fields.Function(
        fields.Char("Bank Account Country Code"),
        'on_change_with_es_sepa_bank_account_country_code')
    es_sepa_request_advancement = fields.Boolean("Request Advancement",
        states={
            'invisible': ((Eval('process_method') != 'sepa')
                | (Eval('es_sepa_bank_account_country_code') != 'ES')),
            },
        help="Check to receive payments before the payment date.")

    @fields.depends('sepa_bank_account_number')
    def on_change_with_es_sepa_bank_account_country_code(self, name=None):
        if self.sepa_bank_account_number:
            return self.sepa_bank_account_number.number[:2]


class Group(metaclass=PoolMeta):
    __name__ = 'account.payment.group'

    @property
    def sepa_message_id(self):
        message_id = super().sepa_message_id
        if (self.kind == 'receivable'
                and self.journal.es_sepa_request_advancement):
            message_id = 'FSDD%s' % message_id
        return message_id