diff --git a/account_banking_pain_base/models/account_payment_line.py b/account_banking_pain_base/models/account_payment_line.py
index c430b5cff..a460b9551 100644
--- a/account_banking_pain_base/models/account_payment_line.py
+++ b/account_banking_pain_base/models/account_payment_line.py
@@ -15,10 +15,47 @@ class AccountPaymentLine(models.Model):
string='Priority', default='NORM',
help="This field will be used as 'Instruction Priority' in "
"the generated PAIN file.")
- # local_instrument is used in some countries, for example
- # switzerland, cf l10n_ch_sepa that adds some entries in
- # the selection field
+ # local_instrument is used for instant credit transfers which
+ # will begin on November 2017, cf account_banking_sepa_credit_transfer
+ # It is also used in some countries such as switzerland,
+ # cf l10n_ch_pain_base that adds some entries in the selection field
local_instrument = fields.Selection([], string='Local Instrument')
+ category_purpose = fields.Selection([
+ # Full category purpose list found on:
+ # https://www.iso20022.org/external_code_list.page
+ # Document "External Code Sets spreadsheet" version Feb 8th 2017
+ ('BONU', 'Bonus Payment'),
+ ('CASH', 'Cash Management Transfer'),
+ ('CBLK', 'Card Bulk Clearing'),
+ ('CCRD', 'Credit Card Payment'),
+ ('CORT', 'Trade Settlement Payment'),
+ ('DCRD', 'Debit Card Payment'),
+ ('DIVI', 'Dividend'),
+ ('DVPM', 'Deliver Against Payment'),
+ ('EPAY', 'ePayment'),
+ ('FCOL', 'Fee Collection'),
+ ('GOVT', 'Government Payment'),
+ ('HEDG', 'Hedging'),
+ ('ICCP', 'Irrevocable Credit Card Payment'),
+ ('IDCP', 'Irrevocable Debit Card Payment'),
+ ('INTC', 'Intra-Company Payment'),
+ ('INTE', 'Interest'),
+ ('LOAN', 'Loan'),
+ ('OTHR', 'Other Payment'),
+ ('PENS', 'Pension Payment'),
+ ('RVPM', 'Receive Against Payment'),
+ ('SALA', 'Salary Payment'),
+ ('SECU', 'Securities'),
+ ('SSBE', 'Social Security Benefit'),
+ ('SUPP', 'Supplier Payment'),
+ ('TAXS', 'Tax Payment'),
+ ('TRAD', 'Trade'),
+ ('TREA', 'Treasury Payment'),
+ ('VATX', 'VAT Payment'),
+ ('WHLD', 'WithHolding'),
+ ], string="Category Purpose",
+ help="If neither your bank nor your local regulations oblige you to "
+ "set the category purpose, leave the field empty.")
# PAIN allows 140 characters
communication = fields.Char(size=140)
# The field struct_communication_type has been dropped in v9
diff --git a/account_banking_pain_base/models/account_payment_order.py b/account_banking_pain_base/models/account_payment_order.py
index 4e62f6a99..751096e22 100644
--- a/account_banking_pain_base/models/account_payment_order.py
+++ b/account_banking_pain_base/models/account_payment_order.py
@@ -203,8 +203,8 @@ class AccountPaymentOrder(models.Model):
@api.model
def generate_start_payment_info_block(
self, parent_node, payment_info_ident,
- priority, local_instrument, sequence_type, requested_date,
- eval_ctx, gen_args):
+ priority, local_instrument, category_purpose, sequence_type,
+ requested_date, eval_ctx, gen_args):
payment_info = etree.SubElement(parent_node, 'PmtInf')
payment_info_identification = etree.SubElement(
payment_info, 'PmtInfId')
@@ -249,7 +249,12 @@ class AccountPaymentOrder(models.Model):
sequence_type_node = etree.SubElement(
payment_type_info, 'SeqTp')
sequence_type_node.text = sequence_type
-
+ if category_purpose:
+ category_purpose_node = etree.SubElement(
+ payment_type_info, 'CtgyPurp')
+ category_purpose_code = etree.SubElement(
+ category_purpose_node, 'Cd')
+ category_purpose_code.text = category_purpose
if gen_args['payment_method'] == 'DD':
request_date_tag = 'ReqdColltnDt'
else:
diff --git a/account_banking_pain_base/models/bank_payment_line.py b/account_banking_pain_base/models/bank_payment_line.py
index dde080637..c055ac5b4 100644
--- a/account_banking_pain_base/models/bank_payment_line.py
+++ b/account_banking_pain_base/models/bank_payment_line.py
@@ -13,10 +13,12 @@ class BankPaymentLine(models.Model):
local_instrument = fields.Selection(
related='payment_line_ids.local_instrument',
string='Local Instrument')
+ category_purpose = fields.Selection(
+ related='payment_line_ids.category_purpose', string='Category Purpose')
@api.model
def same_fields_payment_line_and_bank_payment_line(self):
res = super(BankPaymentLine, self).\
same_fields_payment_line_and_bank_payment_line()
- res += ['priority', 'local_instrument']
+ res += ['priority', 'local_instrument', 'category_purpose']
return res
diff --git a/account_banking_pain_base/views/account_payment_line.xml b/account_banking_pain_base/views/account_payment_line.xml
index e84958e63..925f43e49 100644
--- a/account_banking_pain_base/views/account_payment_line.xml
+++ b/account_banking_pain_base/views/account_payment_line.xml
@@ -13,7 +13,8 @@
-
+
+
diff --git a/account_banking_pain_base/views/bank_payment_line_view.xml b/account_banking_pain_base/views/bank_payment_line_view.xml
index f9496dffd..d6d05a9b3 100644
--- a/account_banking_pain_base/views/bank_payment_line_view.xml
+++ b/account_banking_pain_base/views/bank_payment_line_view.xml
@@ -13,7 +13,8 @@
-
+
+