Add field local_instrument in payment lines and bank payment lines

This commit is contained in:
Alexis de Lattre
2016-06-05 00:44:27 +02:00
parent 7370d174f0
commit b094ad5da8
5 changed files with 16 additions and 5 deletions

View File

@@ -15,6 +15,10 @@ 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 = fields.Selection([], string='Local Instrument')
# PAIN allows 140 characters
communication = fields.Char(size=140)
# The field struct_communication_type has been dropped in v9

View File

@@ -10,10 +10,13 @@ class BankPaymentLine(models.Model):
priority = fields.Selection(
related='payment_line_ids.priority', string='Priority')
local_instrument = fields.Selection(
related='payment_line_ids.local_instrument',
string='Local Instrument')
@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']
res += ['priority', 'local_instrument']
return res

View File

@@ -14,6 +14,7 @@
<field name="arch" type="xml">
<field name="communication_type" position="before">
<field name="priority"/>
<field name="local_instrument" invisible="1"/>
</field>
</field>
</record>

View File

@@ -14,6 +14,7 @@
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
<field name="priority"/>
<field name="local_instrument" invisible="1"/>
</field>
</field>
</record>

View File

@@ -81,27 +81,29 @@ class AccountPaymentOrder(models.Model):
transactions_count_1_6 = 0
amount_control_sum_1_7 = 0.0
lines_per_group = {}
# key = (requested_date, priority)
# key = (requested_date, priority, local_instrument)
# values = list of lines as object
for line in self.bank_line_ids:
priority = line.priority
local_instrument = line.local_instrument
# The field line.date is the requested payment date
# taking into account the 'date_prefered' setting
# cf account_banking_payment_export/models/account_payment.py
# in the inherit of action_open()
key = (line.date, priority)
key = (line.date, priority, local_instrument)
if key in lines_per_group:
lines_per_group[key].append(line)
else:
lines_per_group[key] = [line]
for (requested_date, priority), lines in lines_per_group.items():
for (requested_date, priority, local_instrument), lines in\
lines_per_group.items():
# B. Payment info
payment_info_2_0, nb_of_transactions_2_4, control_sum_2_5 = \
self.generate_start_payment_info_block(
pain_root,
"self.name + '-' "
"+ requested_date.replace('-', '') + '-' + priority",
priority, False, False, requested_date, {
priority, local_instrument, False, requested_date, {
'self': self,
'priority': priority,
'requested_date': requested_date,