diff --git a/CHANGELOG b/CHANGELOG
index 695b19296e..1da2d9a070 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+* Allow to always use RCUR
+
Version 4.0.0 - 2016-05-02
* Bug fixes (see mercurial logs for details)
* Add Python3 support
diff --git a/payment.py b/payment.py
index b178bed8cb..6bfc5848cf 100644
--- a/payment.py
+++ b/payment.py
@@ -368,6 +368,12 @@ class Mandate(Workflow, ModelSQL, ModelView):
'readonly': Eval('state').in_(['validated', 'canceled']),
},
depends=['state'])
+ sequence_type_rcur = fields.Boolean(
+ "Always use RCUR",
+ states={
+ 'invisible': Eval('type') == 'one-off',
+ },
+ depends=['type'])
scheme = fields.Selection([
('CORE', 'Core'),
('B2B', 'Business to Business'),
@@ -437,6 +443,10 @@ class Mandate(Workflow, ModelSQL, ModelView):
def default_type():
return 'recurrent'
+ @classmethod
+ def default_sequence_type_rcur(cls):
+ return False
+
@staticmethod
def default_scheme():
return 'CORE'
@@ -510,7 +520,7 @@ class Mandate(Workflow, ModelSQL, ModelView):
def sequence_type(self):
if self.type == 'one-off':
return 'OOFF'
- elif (not self.payments
+ elif not self.sequence_type_rcur and (not self.payments
or all(not p.sepa_mandate_sequence_type for p in self.payments)
or all(p.rejected for p in self.payments)):
return 'FRST'
diff --git a/tests/test_account_payment_sepa.py b/tests/test_account_payment_sepa.py
index d669d62574..6a820f124f 100644
--- a/tests/test_account_payment_sepa.py
+++ b/tests/test_account_payment_sepa.py
@@ -78,6 +78,7 @@ def setup_mandate(company, customer, account):
'account_number': account.numbers[0],
'identification': 'MANDATE',
'type': 'recurrent',
+ 'sequence_type_rcur': False,
'signature_date': Date.today(),
'state': 'validated',
}])[0]
@@ -291,10 +292,15 @@ class AccountPaymentSepaTestCase(ModuleTestCase):
with set_company(company):
company_account, customer_account = setup_accounts(
bank, company, customer)
- setup_mandate(company, customer, customer_account)
+ mandate = setup_mandate(company, customer, customer_account)
journal = setup_journal('pain.008.001.02', 'receivable',
company, company_account)
+ self.assertEqual(mandate.sequence_type, 'FRST')
+ mandate.sequence_type_rcur = True
+ self.assertEqual(mandate.sequence_type, 'RCUR')
+ mandate.sequence_type_rcur = False
+
payment, = Payment.create([{
'company': company,
'party': customer,
diff --git a/view/mandate_form.xml b/view/mandate_form.xml
index 291f0232d1..598438900d 100644
--- a/view/mandate_form.xml
+++ b/view/mandate_form.xml
@@ -15,6 +15,8 @@ this repository contains the full copyright notices and license terms. -->
+
+