Files
tryton/account.py
T

52 lines
1.9 KiB
Python
Raw Normal View History

2014-12-02 12:54:47 +01:00
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
2017-04-01 00:27:02 +02:00
from trytond import backend
from trytond.pool import PoolMeta
2017-04-01 00:27:02 +02:00
from trytond.model import ModelSQL, fields
2014-12-03 16:16:17 +01:00
from trytond.pyson import Eval
2017-04-01 00:27:02 +02:00
from trytond.tools.multivalue import migrate_property
from trytond.modules.company.model import CompanyValueMixin
2017-04-01 00:27:02 +02:00
__all__ = ['Configuration', 'ConfigurationSepaMandateSequence']
2018-06-26 19:11:43 +02:00
class Configuration(metaclass=PoolMeta):
__name__ = 'account.configuration'
2017-04-01 00:27:02 +02:00
sepa_mandate_sequence = fields.MultiValue(fields.Many2One(
'ir.sequence', "SEPA Mandate Sequence",
domain=[
('code', '=', 'account.payment.sepa.mandate'),
2014-12-03 16:16:17 +01:00
('company', 'in', [Eval('context', {}).get('company', -1),
None]),
]))
2017-04-01 00:27:02 +02:00
class ConfigurationSepaMandateSequence(ModelSQL, CompanyValueMixin):
"Account Configuration SEPA Mandate Sequence"
__name__ = 'account.configuration.sepa_mandate_sequence'
sepa_mandate_sequence = fields.Many2One(
'ir.sequence', "SEPA Mandate Sequence",
domain=[
('code', '=', 'account.payment.sepa.mandate'),
('company', 'in', [Eval('company', -1), None]),
2017-04-01 00:27:02 +02:00
],
depends=['company'])
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
exist = TableHandler.table_exist(cls._table)
super(ConfigurationSepaMandateSequence, cls).__register__(module_name)
if not exist:
cls._migrate_property([], [], [])
@classmethod
def _migrate_property(cls, field_names, value_names, fields):
field_names.append('sepa_mandate_sequence')
value_names.append('sepa_mandate_sequence')
fields.append('company')
migrate_property(
'account.configuration', field_names, cls, value_names,
fields=fields)