diff --git a/__init__.py b/__init__.py
index a0d4d980be..e67931da7d 100644
--- a/__init__.py
+++ b/__init__.py
@@ -15,8 +15,10 @@ def register():
ProcessPaymentStart,
PayLineAskJournal,
Configuration,
+ ConfigurationPaymentGroupSequence,
Invoice,
party.Party,
+ party.PartyPaymentDirectDebit,
module='account_payment', type_='model')
Pool.register(
ProcessPayment,
diff --git a/account.py b/account.py
index 9e0be10a9f..810efdf1b8 100644
--- a/account.py
+++ b/account.py
@@ -7,16 +7,20 @@ from sql.aggregate import Sum
from sql.conditionals import Case, Coalesce
from sql.functions import Abs
+from trytond import backend
from trytond.pool import Pool, PoolMeta
-from trytond.model import ModelView, fields
+from trytond.model import ModelSQL, ModelView, fields
from trytond.pyson import Eval, If, Bool
from trytond.wizard import (Wizard, StateView, StateAction, StateTransition,
Button)
from trytond.transaction import Transaction
+from trytond.tools.multivalue import migrate_property
+from trytond.modules.company.model import CompanyValueMixin
from .payment import KINDS
-__all__ = ['MoveLine', 'PayLine', 'PayLineAskJournal', 'Configuration',
+__all__ = ['MoveLine', 'PayLine', 'PayLineAskJournal',
+ 'Configuration', 'ConfigurationPaymentGroupSequence',
'Invoice']
@@ -302,12 +306,56 @@ class PayLine(Wizard):
class Configuration:
__metaclass__ = PoolMeta
__name__ = 'account.configuration'
- payment_group_sequence = fields.Property(fields.Many2One('ir.sequence',
- 'Payment Group Sequence', domain=[
+ payment_group_sequence = fields.MultiValue(fields.Many2One(
+ 'ir.sequence', 'Payment Group Sequence', required=True,
+ domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'account.payment.group'),
- ], required=True))
+ ]))
+
+ @classmethod
+ def default_payment_group_sequence(cls):
+ return cls.multivalue_model(
+ 'payment_group_sequence').default_payment_group_sequence()
+
+
+class ConfigurationPaymentGroupSequence(ModelSQL, CompanyValueMixin):
+ "Account Configuration Payment Group Sequence"
+ __name__ = 'account.configuration.payment_group_sequence'
+ payment_group_sequence = fields.Many2One(
+ 'ir.sequence', "Payment Group Sequence", required=True,
+ domain=[
+ ('company', 'in', [Eval('company', -1), None]),
+ ('code', '=', 'account.payment.group'),
+ ],
+ depends=['company'])
+
+ @classmethod
+ def __register__(cls, module_name):
+ TableHandler = backend.get('TableHandler')
+ exist = TableHandler.table_exist(cls._table)
+
+ super(ConfigurationPaymentGroupSequence, cls).__register__(module_name)
+
+ if not exist:
+ cls._migrate_property([], [], [])
+
+ @classmethod
+ def _migrate_property(cls, field_names, value_names, fields):
+ field_names.append('payment_group_sequence')
+ value_names.append('payment_group_sequence')
+ fields.append('company')
+ migrate_property(
+ 'account.configuration', field_names, cls, value_names,
+ fields=fields)
+
+ @classmethod
+ def default_payment_group_sequence(cls):
+ pool = Pool()
+ ModelData = pool.get('ir.model.data')
+ return ModelData.get_id(
+ 'account_payment', 'sequence_account_payment_group')
class Invoice:
diff --git a/account.xml b/account.xml
index e238df596d..e528490178 100644
--- a/account.xml
+++ b/account.xml
@@ -122,13 +122,6 @@ this repository contains the full copyright notices and license terms. -->
configuration_form
-
-
-
-
-
-
account.invoice
diff --git a/party.py b/party.py
index cb9e1c0e46..deb1963116 100644
--- a/party.py
+++ b/party.py
@@ -1,35 +1,33 @@
# 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.pool import PoolMeta
-from trytond.model import fields
+from trytond.model import ModelSQL, fields
+from trytond.modules.company.model import CompanyValueMixin
-__all__ = ['Party', 'PartyReplace']
+__all__ = ['Party', 'PartyPaymentDirectDebit', 'PartyReplace']
+payment_direct_debit = fields.Boolean(
+ "Direct Debit", help="Check if supplier does direct debit.")
class Party:
__metaclass__ = PoolMeta
__name__ = 'party.party'
- payment_direct_debit_int = fields.Property(
- fields.Integer("Direct Debit Internal"))
- payment_direct_debit = fields.Function(
- fields.Boolean(
- "Direct Debit", help="Check if supplier does direct debit."),
- 'get_payment_direct_debit', setter='set_payment_direct_debit')
+ payment_direct_debit = fields.MultiValue(payment_direct_debit)
+ payment_direct_debits = fields.One2Many(
+ 'party.party.payment_direct_debit', 'party', "Direct Debits")
@classmethod
- def default_payment_direct_debit(cls):
+ def default_payment_direct_debit(cls, **pattern):
return False
- def get_payment_direct_debit(self, name):
- return bool(self.payment_direct_debit_int)
- @classmethod
- def set_payment_direct_debit(cls, parties, name, value):
- cls.write(parties, {
- 'payment_direct_debit_int': (
- int(value) if value is not None else None),
- })
+class PartyPaymentDirectDebit(ModelSQL, CompanyValueMixin):
+ "Party Payment Direct Debit"
+ __name__ = 'party.party.payment_direct_debit'
+ party = fields.Many2One(
+ 'party.party', "Party", ondelete='CASCADE', select=True)
+ payment_direct_debit = payment_direct_debit
class PartyReplace:
diff --git a/tests/scenario_account_payment_invoice.rst b/tests/scenario_account_payment_invoice.rst
index effd462441..52d8bcfcb3 100644
--- a/tests/scenario_account_payment_invoice.rst
+++ b/tests/scenario_account_payment_invoice.rst
@@ -118,7 +118,7 @@ Create invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.party = party
- >>> invoice.payment_direct_debit
+ >>> bool(invoice.payment_direct_debit)
True
>>> line = invoice.lines.new()
>>> line.description = 'Description'