Files
tryton/modules/account_payment_sepa_cfonb/payment.py
T

49 lines
1.6 KiB
Python
Raw Normal View History

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os
import genshi
import genshi.template
from trytond.modules.account_payment_sepa import payment as sepa_payment
2021-12-11 17:58:41 +01:00
from trytond.pool import PoolMeta
2018-06-26 19:11:43 +02:00
class Journal(metaclass=PoolMeta):
__name__ = 'account.payment.journal'
@classmethod
def __setup__(cls):
2025-04-04 00:45:18 +02:00
super().__setup__()
payable_flavor_cfonb = ('pain.001.001.03-cfonb',
'pain.001.001.03 CFONB')
receivable_flavor_cfonb = ('pain.008.001.02-cfonb',
'pain.008.001.02 CFONB')
for flavor, field in [
(payable_flavor_cfonb, cls.sepa_payable_flavor),
(receivable_flavor_cfonb, cls.sepa_receivable_flavor),
]:
if flavor not in field.selection:
field.selection.append(flavor)
2020-03-01 12:33:51 +01:00
loader = genshi.template.TemplateLoader([
os.path.join(os.path.dirname(__file__), 'template'),
os.path.join(
os.path.dirname(
sepa_payment.__file__), 'template'),
], auto_reload=True)
2018-06-26 19:11:43 +02:00
class Group(metaclass=PoolMeta):
__name__ = 'account.payment.group'
def get_sepa_template(self):
if (self.kind == 'payable'
and self.journal.sepa_payable_flavor.endswith('-cfonb')):
return loader.load('%s.xml' % self.journal.sepa_payable_flavor)
if (self.kind == 'receivable'
and self.journal.sepa_receivable_flavor.endswith('-cfonb')):
return loader.load('%s.xml' % self.journal.sepa_receivable_flavor)
2025-04-04 00:45:18 +02:00
return super().get_sepa_template()