Merge lp:~compassion/banking-addons/banking-addons-mandate into lp:banking-addons

Proposed by Nicolas Bessi - Camptocamp
Status: Work in progress
Proposed branch: lp:~compassion/banking-addons/banking-addons-mandate
Merge into: lp:banking-addons
Diff against target: 1483 lines (+704/-333)
21 files modified
account_banking_mandate/__init__.py (+22/-0)
account_banking_mandate/__openerp__.py (+46/-0)
account_banking_mandate/data/mandate_reference_sequence.xml (+6/-6)
account_banking_mandate/model/__init__.py (+26/-0)
account_banking_mandate/model/account_banking_mandate.py (+185/-0)
account_banking_mandate/model/account_invoice.py (+34/-0)
account_banking_mandate/model/partner_bank.py (+33/-0)
account_banking_mandate/model/payment_line.py (+100/-0)
account_banking_mandate/view/account_banking_mandate_view.xml (+31/-59)
account_banking_mandate/view/account_invoice_view.xml (+2/-2)
account_banking_mandate/view/account_payment_view.xml (+4/-4)
account_banking_mandate/view/res_partner_bank_view.xml (+11/-12)
account_banking_payment_export/model/payment_order_create.py (+6/-0)
account_banking_sepa_direct_debit/__openerp__.py (+2/-5)
account_banking_sepa_direct_debit/account_banking_sdd.py (+13/-212)
account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml (+17/-0)
account_banking_sepa_direct_debit/mandate_expire_cron.xml (+1/-1)
account_banking_sepa_direct_debit/sdd_mandate_view.xml (+133/-0)
account_banking_sepa_direct_debit/security/ir.model.access.csv (+2/-2)
account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml (+1/-1)
account_banking_sepa_direct_debit/wizard/export_sdd.py (+29/-29)
To merge this branch: bzr merge lp:~compassion/banking-addons/banking-addons-mandate
Reviewer Review Type Date Requested Status
Cyril Sester (community) Needs Resubmitting
Nicolas Bessi - Camptocamp (community) Needs Fixing
Review via email: mp+224428@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

Temporary MP to help review

Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

See my comments inline

review: Needs Fixing
262. By Cyril Sester

Refactoring, fixed auto add for mandate

263. By Cyril Sester

Fixed initial author. Add SDD ref sequence to stay consistent with previous code.

264. By Cyril Sester

Merged trunk modifs

265. By Cyril Sester

Merge changes

Revision history for this message
Cyril Sester (cyril-sester) wrote :

> See my comments inline

Code has be fixed accordly to comments.

review: Needs Resubmitting

Unmerged revisions

265. By Cyril Sester

Merge changes

264. By Cyril Sester

Merged trunk modifs

263. By Cyril Sester

Fixed initial author. Add SDD ref sequence to stay consistent with previous code.

262. By Cyril Sester

Refactoring, fixed auto add for mandate

261. By Cyril Sester

Merged trunk changes into branch

260. By Cyril Sester

Some comments and refactorings

259. By Cyril Sester <email address hidden>

SEPA demo install correction. Mandate bank onchange method corrected (wrong parent call fixed)

258. By Cyril Sester <email address hidden>

Add SEPA to menuitem/action name/forms titles

257. By Cyril Sester <email address hidden>

sepa mandate splitted to get a generic mandate

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_banking_mandate'
=== added file 'account_banking_mandate/__init__.py'
--- account_banking_mandate/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/__init__.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,22 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as
10# published by the Free Software Foundation, either version 3 of the
11# License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22import model
0\ No newline at end of file23\ No newline at end of file
124
=== added file 'account_banking_mandate/__openerp__.py'
--- account_banking_mandate/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/__openerp__.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,46 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23{
24 'name': 'Account Banking Mandate',
25 'summary': 'Direct Debit mandate',
26 'version': '0.1',
27 'license': 'AGPL-3',
28 'author': 'Compassion CH',
29 'website': 'http://www.compassion.ch',
30 'category': 'Banking addons',
31 'depends': ['account_payment'],
32 'external_dependencies': {},
33 'data': [
34 'view/account_banking_mandate_view.xml',
35 'view/account_invoice_view.xml',
36 'view/account_payment_view.xml',
37 'view/res_partner_bank_view.xml',
38 'data/mandate_reference_sequence.xml',
39 ],
40 'demo': [],
41 'description': '''This module adds a generic model for banking mandates. These mandates can be specialized to
42fit any banking mandates (such as sepa or lsv).
43''',
44 'active': False,
45 'installable': True,
46}
047
=== added directory 'account_banking_mandate/data'
=== renamed file 'account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml' => 'account_banking_mandate/data/mandate_reference_sequence.xml'
--- account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml 2013-10-22 22:25:06 +0000
+++ account_banking_mandate/data/mandate_reference_sequence.xml 2014-07-29 07:49:30 +0000
@@ -3,14 +3,14 @@
3<data noupdate="1">3<data noupdate="1">
44
55
6<record id="sdd_mandate_seq_type" model="ir.sequence.type">6<record id="dd_mandate_seq_type" model="ir.sequence.type">
7 <field name="name">SDD Mandate Reference</field>7 <field name="name">DD Mandate Reference</field>
8 <field name="code">sdd.mandate.reference</field>8 <field name="code">account.banking.mandate</field>
9</record>9</record>
1010
11<record id="sdd_mandate_seq" model="ir.sequence">11<record id="dd_mandate_seq" model="ir.sequence">
12 <field name="name">SDD Mandate Reference</field>12 <field name="name">DD Mandate Reference</field>
13 <field name="code">sdd.mandate.reference</field>13 <field name="code">account.banking.mandate</field>
14 <field name="prefix">RUM</field>14 <field name="prefix">RUM</field>
15 <field name="padding" eval="7"/>15 <field name="padding" eval="7"/>
16 <!-- remember that max size for the mandate ref is 35 -->16 <!-- remember that max size for the mandate ref is 35 -->
1717
=== added directory 'account_banking_mandate/model'
=== added file 'account_banking_mandate/model/__init__.py'
--- account_banking_mandate/model/__init__.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/__init__.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23from . import account_banking_mandate
24from . import account_invoice
25from . import partner_bank
26from . import payment_line
0\ No newline at end of file27\ No newline at end of file
128
=== added file 'account_banking_mandate/model/account_banking_mandate.py'
--- account_banking_mandate/model/account_banking_mandate.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/account_banking_mandate.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,185 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from datetime import datetime
25import logging
26from openerp.osv import orm, fields
27from openerp.tools.translate import _
28
29logger = logging.getLogger(__name__)
30
31class mandate(orm.Model):
32 ''' The banking mandate is attached to a bank account and represents an
33 authorization that the bank account owner gives to a company for a specific operation
34 (such as direct debit)
35 '''
36 _name = 'account.banking.mandate'
37 _description = "A generic banking mandate"
38 _rec_name = 'unique_mandate_reference'
39 _inherit = ['mail.thread']
40 _order = 'signature_date desc'
41 _track = {
42 'state': {
43 'account_banking_mandate.mandate_valid':
44 lambda self, cr, uid, obj, ctx=None:
45 obj['state'] == 'valid',
46 'account_banking_mandate.mandate_expired':
47 lambda self, cr, uid, obj, ctx=None:
48 obj['state'] == 'expired',
49 'account_banking_mandate.mandate_cancel':
50 lambda self, cr, uid, obj, ctx=None:
51 obj['state'] == 'cancel',
52 },
53 }
54
55 def _get_states(self, cr, uid, context=None):
56 return (
57 ('draft', 'Draft'),
58 ('valid', 'Valid'),
59 ('expired', 'Expired'),
60 ('cancel', 'Cancelled'),)
61
62 _columns = {
63 'partner_bank_id': fields.many2one(
64 'res.partner.bank', 'Bank Account', track_visibility='onchange'),
65 'partner_id': fields.related(
66 'partner_bank_id', 'partner_id', type='many2one',
67 relation='res.partner', string='Partner', readonly=True),
68 'company_id': fields.many2one('res.company', 'Company', required=True),
69 'unique_mandate_reference': fields.char(
70 'Unique Mandate Reference', size=35, readonly=True,
71 track_visibility='always'),
72 'signature_date': fields.date(
73 'Date of Signature of the Mandate', track_visibility='onchange'),
74 'scan': fields.binary('Scan of the Mandate'),
75 'last_debit_date': fields.date(
76 'Date of the Last Debit', readonly=True),
77 'state': fields.selection(_get_states, 'Status',
78 help="Only valid mandates can be used in a payment line. A "
79 "cancelled mandate is a mandate that has been cancelled by "
80 "the customer. "),
81 'payment_line_ids': fields.one2many(
82 'payment.line', 'mandate_id', "Related Payment Lines"),
83 }
84
85 _defaults = {
86 'company_id': lambda self, cr, uid, context:
87 self.pool['res.company']._company_default_get(
88 cr, uid, 'account.banking.mandate', context=context),
89 'state': 'draft',
90 'unique_mandate_reference': '/',
91 }
92
93 _sql_constraints = [(
94 'mandate_ref_company_uniq',
95 'unique(unique_mandate_reference, company_id)',
96 'A Mandate with the same reference already exists for this company !'
97 )]
98
99 def create(self, cr, uid, vals, context=None):
100 if vals.get('unique_mandate_reference', '/') == '/':
101 sequence = self.pool['ir.sequence']
102 next_value = sequence.next_by_code(cr, uid, 'account.banking.mandate', context=context)
103 vals['unique_mandate_reference'] = next_value
104
105 return super(mandate, self).create(cr, uid, vals, context=context)
106
107 def _check_dates(self, cr, uid, ids):
108 for mandate in self.browse(cr, uid, ids):
109 if (mandate.signature_date and
110 mandate.signature_date >
111 datetime.today().strftime('%Y-%m-%d')):
112 raise orm.except_orm(
113 _('Error:'),
114 _("The date of signature of mandate '%s' is in the "
115 "future !")
116 % mandate.unique_mandate_reference)
117
118 if (mandate.signature_date and mandate.last_debit_date and
119 mandate.signature_date > mandate.last_debit_date):
120 raise orm.except_orm(
121 _('Error:'),
122 _("The mandate '%s' can't have a date of last debit "
123 "before the date of signature.")
124 % mandate.unique_mandate_reference)
125 return True
126
127 def _check_valid_state(self, cr, uid, ids):
128 for mandate in self.browse(cr, uid, ids):
129 if mandate.state == 'valid' and not mandate.signature_date:
130 raise orm.except_orm(
131 _('Error:'),
132 _("Cannot validate the mandate '%s' without a date of "
133 "signature.")
134 % mandate.unique_mandate_reference)
135 if mandate.state == 'valid' and not mandate.partner_bank_id:
136 raise orm.except_orm(
137 _('Error:'),
138 _("Cannot validate the mandate '%s' because it is not "
139 "attached to a bank account.")
140 % mandate.unique_mandate_reference)
141 return True
142
143 _constraints = [
144 (_check_dates, "Error msg in raise", ['signature_date', 'last_debit_date']),
145 (_check_valid_state, "Error msg in raise", ['state', 'partner_bank_id']),
146 ]
147
148 def mandate_partner_bank_change(
149 self, cr, uid, ids, partner_bank_id, last_debit_date, state, context=None):
150 res = {'value': {}}
151 if partner_bank_id:
152 partner_bank_read = self.pool['res.partner.bank'].read(
153 cr, uid, partner_bank_id, ['partner_id'])['partner_id']
154 if partner_bank_read:
155 res['value']['partner_id'] = partner_bank_read[0]
156 return res
157
158 def validate(self, cr, uid, ids, context=None):
159 to_validate_ids = []
160 for mandate in self.browse(cr, uid, ids, context=context):
161 assert mandate.state == 'draft', 'Mandate should be in draft state'
162 to_validate_ids.append(mandate.id)
163 self.write(
164 cr, uid, to_validate_ids, {'state': 'valid'}, context=context)
165 return True
166
167 def cancel(self, cr, uid, ids, context=None):
168 to_cancel_ids = []
169 for mandate in self.browse(cr, uid, ids, context=context):
170 assert mandate.state in ('draft', 'valid'),\
171 'Mandate should be in draft or valid state'
172 to_cancel_ids.append(mandate.id)
173 self.write(
174 cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context)
175 return True
176
177 def back2draft(self, cr, uid, ids, context=None):
178 to_draft_ids = []
179 for mandate in self.browse(cr, uid, ids, context=context):
180 assert mandate.state == 'cancel',\
181 'Mandate should be in cancel state'
182 to_draft_ids.append(mandate.id)
183 self.write(
184 cr, uid, to_draft_ids, {'state': 'draft'}, context=context)
185 return True
0\ No newline at end of file186\ No newline at end of file
1187
=== added file 'account_banking_mandate/model/account_invoice.py'
--- account_banking_mandate/model/account_invoice.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/account_invoice.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,34 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from openerp.osv import orm, fields
25
26class account_invoice(orm.Model):
27 _inherit = 'account.invoice'
28
29 _columns = {
30 'mandate_id': fields.many2one(
31 'account.banking.mandate', 'Direct Debit Mandate',
32 domain=[('state', '=', 'valid')], readonly=True,
33 states={'draft': [('readonly', False)]})
34 }
0\ No newline at end of file35\ No newline at end of file
136
=== added file 'account_banking_mandate/model/partner_bank.py'
--- account_banking_mandate/model/partner_bank.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/partner_bank.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,33 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from openerp.osv import orm, fields
25
26class res_partner_bank(orm.Model):
27 _inherit = 'res.partner.bank'
28
29 #Add mandate references on bank account (a bank account can have several mandates)
30 _columns = {
31 'mandate_ids': fields.one2many(
32 'account.banking.mandate', 'partner_bank_id', 'Banking Mandates'),
33 }
0\ No newline at end of file34\ No newline at end of file
135
=== added file 'account_banking_mandate/model/payment_line.py'
--- account_banking_mandate/model/payment_line.py 1970-01-01 00:00:00 +0000
+++ account_banking_mandate/model/payment_line.py 2014-07-29 07:49:30 +0000
@@ -0,0 +1,100 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Mandate module for openERP
5# Copyright (C) 2014 Compassion CH (http://www.compassion.ch)
6# @author: Cyril Sester <csester@compassion.ch>,
7# Alexis de Lattre <alexis.delattre@akretion.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from openerp.osv import orm, fields
25
26import logging
27
28logger = logging.getLogger(__name__)
29
30class payment_line(orm.Model):
31 _inherit = 'payment.line'
32
33 #Add mandate reference on payment line (several payment line can referer to same mandate)
34 _columns = {
35 'mandate_id': fields.many2one(
36 'account.banking.mandate', 'Direct Debit Mandate',
37 domain=[('state', '=', 'valid')]),
38 }
39
40 def create(self, cr, uid, vals, context=None):
41 '''If the customer invoice has a mandate, take it
42 otherwise, take the first valid mandate of the bank account.
43 This is done here and not in _defaults because we need the context.
44 '''
45 if context is None:
46 context = {}
47 if not vals:
48 vals = {}
49 partner_bank_id = vals.get('bank_id')
50 move_line_id = vals.get('move_line_id')
51 logger.info("partner_bank_id: %s" % partner_bank_id)
52 logger.info("move_line_id: %s" % move_line_id)
53 logger.info("context: %s" % context)
54 logger.info("vals : %s" % vals)
55 if (context.get('search_payment_order_type') == 'debit'
56 and 'mandate_id' not in vals):
57 if move_line_id:
58 line = self.pool['account.move.line'].browse(
59 cr, uid, move_line_id, context=context)
60 if (line.invoice and line.invoice.type == 'out_invoice'
61 and line.invoice.mandate_id):
62 vals.update({
63 'mandate_id': line.invoice.mandate_id.id,
64 'bank_id':
65 line.invoice.mandate_id.partner_bank_id.id,
66 })
67 if partner_bank_id and 'mandate_id' not in vals:
68 mandate_ids = self.pool['account.banking.mandate'].search(cr, uid, [
69 ('partner_bank_id', '=', partner_bank_id),
70 ('state', '=', 'valid'),
71 ], context=context)
72 if mandate_ids:
73 vals['mandate_id'] = mandate_ids[0]
74 return super(payment_line, self).create(cr, uid, vals, context=context)
75
76 def _check_mandate_bank_link(self, cr, uid, ids):
77 for payline in self.browse(cr, uid, ids):
78 if (payline.mandate_id and payline.bank_id
79 and payline.mandate_id.partner_bank_id.id !=
80 payline.bank_id.id):
81 raise orm.except_orm(
82 _('Error:'),
83 _("The payment line with reference '%s' has the bank "
84 "account '%s' which is not attached to the mandate "
85 "'%s' (this mandate is attached to the bank account "
86 "'%s').") % (
87 payline.name,
88 self.pool['res.partner.bank'].name_get(
89 cr, uid, [payline.bank_id.id])[0][1],
90 payline.mandate_id.unique_mandate_reference,
91 self.pool['res.partner.bank'].name_get(
92 cr, uid,
93 [payline.mandate_id.partner_bank_id.id])[0][1],
94 ))
95 return True
96
97 _constraints = [
98 (_check_mandate_bank_link, 'Error msg in raise',
99 ['mandate_id', 'bank_id']),
100 ]
0\ No newline at end of file101\ No newline at end of file
1102
=== added directory 'account_banking_mandate/view'
=== renamed file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml' => 'account_banking_mandate/view/account_banking_mandate_view.xml'
--- account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-06-11 22:03:21 +0000
+++ account_banking_mandate/view/account_banking_mandate_view.xml 2014-07-29 07:49:30 +0000
@@ -7,11 +7,11 @@
7<openerp>7<openerp>
8<data>8<data>
99
10<record id="sdd_mandate_form" model="ir.ui.view">10<record id="dd_mandate_form" model="ir.ui.view">
11 <field name="name">sdd.mandate.form</field>11 <field name="name">dd.mandate.form</field>
12 <field name="model">sdd.mandate</field>12 <field name="model">account.banking.mandate</field>
13 <field name="arch" type="xml">13 <field name="arch" type="xml">
14 <form string="SEPA Direct Debit Mandate" version="7.0">14 <form string="Banking Mandate" version="7.0">
15 <header>15 <header>
16 <button name="validate" type="object" string="Validate" states="draft" class="oe_highlight"/>16 <button name="validate" type="object" string="Validate" states="draft" class="oe_highlight"/>
17 <button name="cancel" type="object" string="Cancel" states="draft,valid"/>17 <button name="cancel" type="object" string="Cancel" states="draft,valid"/>
@@ -29,17 +29,13 @@
29 <group name="main">29 <group name="main">
30 <field name="company_id" groups="base.group_multi_company"/>30 <field name="company_id" groups="base.group_multi_company"/>
31 <field name="partner_bank_id"31 <field name="partner_bank_id"
32 on_change="mandate_partner_bank_change(partner_bank_id, type, recurrent_sequence_type, last_debit_date, state)"32 on_change="mandate_partner_bank_change(partner_bank_id, last_debit_date, state)"
33 invisible="context.get('sdd_mandate_bank_partner_view')"33 invisible="context.get('dd_mandate_bank_partner_view')"
34 />34 />
35 <field name="partner_id" invisible="context.get('sdd_mandate_bank_partner_view')"/>35 <field name="partner_id" invisible="context.get('dd_mandate_bank_partner_view')"/>
36 <field name="type" on_change="mandate_type_change(type)"/>
37 <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/>
38 <field name="signature_date"/>36 <field name="signature_date"/>
39 <field name="scan"/>37 <field name="scan"/>
40 <field name="last_debit_date"/>38 <field name="last_debit_date"/>
41 <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
42 <field name="original_mandate_identification" attrs="{'invisible': [('sepa_migrated', '=', True)], 'required': [('sepa_migrated', '=', False)]}" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
43 </group>39 </group>
44 <group name="payment_lines" string="Related Payment Lines">40 <group name="payment_lines" string="Related Payment Lines">
45 <field name="payment_line_ids" nolabel="1"/>41 <field name="payment_line_ids" nolabel="1"/>
@@ -53,15 +49,14 @@
53 </field>49 </field>
54</record>50</record>
5551
56<record id="sdd_mandate_tree" model="ir.ui.view">52<record id="dd_mandate_tree" model="ir.ui.view">
57 <field name="name">sdd.mandate.tree</field>53 <field name="name">dd.mandate.tree</field>
58 <field name="model">sdd.mandate</field>54 <field name="model">account.banking.mandate</field>
59 <field name="arch" type="xml">55 <field name="arch" type="xml">
60 <tree string="SEPA Direct Debit Mandate" colors="blue:state=='draft';black:state in ('expired', 'cancel')">56 <tree string="Banking Mandate" colors="blue:state=='draft';black:state in ('expired', 'cancel')">
61 <field name="company_id" groups="base.group_multi_company"/>57 <field name="company_id" groups="base.group_multi_company"/>
62 <field name="partner_id" invisible="context.get('sdd_mandate_bank_partner_view')"/>58 <field name="partner_id" invisible="context.get('dd_mandate_bank_partner_view')"/>
63 <field name="unique_mandate_reference" string="Reference"/>59 <field name="unique_mandate_reference" string="Reference"/>
64 <field name="type" string="Type"/>
65 <field name="signature_date" string="Signature Date"/>60 <field name="signature_date" string="Signature Date"/>
66 <field name="last_debit_date"/>61 <field name="last_debit_date"/>
67 <field name="state"/>62 <field name="state"/>
@@ -69,83 +64,60 @@
69 </field>64 </field>
70</record>65</record>
7166
72<record id="sdd_mandate_search" model="ir.ui.view">67<record id="dd_mandate_search" model="ir.ui.view">
73 <field name="name">sdd.mandate.search</field>68 <field name="name">dd.mandate.search</field>
74 <field name="model">sdd.mandate</field>69 <field name="model">account.banking.mandate</field>
75 <field name="arch" type="xml">70 <field name="arch" type="xml">
76 <search string="Search SEPA Direct Debit Mandates">71 <search string="Search Banking Mandates">
77 <field name="partner_id"/>72 <field name="partner_id"/>
78 <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" />73 <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" />
79 <filter name="valid" string="Valid" domain="[('state', '=', 'valid')]" />74 <filter name="valid" string="Valid" domain="[('state', '=', 'valid')]" />
80 <filter name="cancel" string="Cancelled" domain="[('state', '=', 'cancel')]" />75 <filter name="cancel" string="Cancelled" domain="[('state', '=', 'cancel')]" />
81 <filter name="expired" string="Expired" domain="[('state', '=', 'expired')]" />76 <filter name="expired" string="Expired" domain="[('state', '=', 'expired')]" />
82 <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" />
83 <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" />
84 </search>77 </search>
85 </field>78 </field>
86</record>79</record>
8780
88<record id="sdd_mandate_action" model="ir.actions.act_window">81<record id="dd_mandate_action" model="ir.actions.act_window">
89 <field name="name">SEPA Direct Debit Mandates</field>82 <field name="name">Banking Mandates</field>
90 <field name="res_model">sdd.mandate</field>83 <field name="res_model">account.banking.mandate</field>
91 <field name="view_type">form</field>84 <field name="view_type">form</field>
92 <field name="view_mode">tree,form</field>85 <field name="view_mode">tree,form</field>
93 <field name="help" type="html">86 <field name="help" type="html">
94 <p class="oe_view_nocontent_create">87 <p class="oe_view_nocontent_create">
95 Click to create a new SEPA Direct Debit Mandate.88 Click to create a new Banking Mandate.
96 </p><p>89 </p><p>
97 A SEPA Direct Debit Mandate is a document signed by your customer that gives you the autorization to do one or several direct debits on his bank account.90 A banking mandate is a document signed by your customer that gives you the autorization to do one or several operations on his bank account.
98 </p>91 </p>
99 </field>92 </field>
100</record>93</record>
10194
102<menuitem id="sdd_mandate_menu"95<menuitem id="dd_mandate_menu"
103 parent="account_payment.menu_main_payment"96 parent="account_payment.menu_main_payment"
104 action="sdd_mandate_action"97 action="dd_mandate_action"
105 sequence="20"98 sequence="20"
106 />99 />
107100
108<!-- notifications in the chatter -->101<!-- notifications statuses in the chatter -->
109<record id="mandate_valid" model="mail.message.subtype">102<record id="mandate_valid" model="mail.message.subtype">
110 <field name="name">Mandate Validated</field>103 <field name="name">Mandate Validated</field>
111 <field name="res_model">sdd.mandate</field>104 <field name="res_model">account.banking.mandate</field>
112 <field name="default" eval="False"/>105 <field name="default" eval="False"/>
113 <field name="description">SEPA Direct Debit Mandate Validated</field>106 <field name="description">Direct Debit Mandate Validated</field>
114</record>107</record>
115108
116<record id="mandate_expired" model="mail.message.subtype">109<record id="mandate_expired" model="mail.message.subtype">
117 <field name="name">Mandate Expired</field>110 <field name="name">Mandate Expired</field>
118 <field name="res_model">sdd.mandate</field>111 <field name="res_model">account.banking.mandate</field>
119 <field name="default" eval="False"/>112 <field name="default" eval="False"/>
120 <field name="description">SEPA Direct Debit Mandate has Expired</field>113 <field name="description">Direct Debit Mandate has Expired</field>
121</record>114</record>
122115
123<record id="mandate_cancel" model="mail.message.subtype">116<record id="mandate_cancel" model="mail.message.subtype">
124 <field name="name">Mandate Cancelled</field>117 <field name="name">Mandate Cancelled</field>
125 <field name="res_model">sdd.mandate</field>118 <field name="res_model">account.banking.mandate</field>
126 <field name="default" eval="False"/>119 <field name="default" eval="False"/>
127 <field name="description">SEPA Direct Debit Mandate Cancelled</field>120 <field name="description">Direct Debit Mandate Cancelled</field>
128</record>
129
130<record id="recurrent_sequence_type_first" model="mail.message.subtype">
131 <field name="name">Sequence Type set to First</field>
132 <field name="res_model">sdd.mandate</field>
133 <field name="default" eval="False"/>
134 <field name="description">Sequence Type set to First</field>
135</record>
136
137<record id="recurrent_sequence_type_recurring" model="mail.message.subtype">
138 <field name="name">Sequence Type set to Recurring</field>
139 <field name="res_model">sdd.mandate</field>
140 <field name="default" eval="False"/>
141 <field name="description">Sequence Type set to Recurring</field>
142</record>
143
144<record id="recurrent_sequence_type_final" model="mail.message.subtype">
145 <field name="name">Sequence Type set to Final</field>
146 <field name="res_model">sdd.mandate</field>
147 <field name="default" eval="False"/>
148 <field name="description">Sequence Type set to Final</field>
149</record>121</record>
150122
151</data>123</data>
152124
=== renamed file 'account_banking_sepa_direct_debit/account_invoice_view.xml' => 'account_banking_mandate/view/account_invoice_view.xml'
--- account_banking_sepa_direct_debit/account_invoice_view.xml 2013-11-09 14:05:07 +0000
+++ account_banking_mandate/view/account_invoice_view.xml 2014-07-29 07:49:30 +0000
@@ -8,12 +8,12 @@
8<data>8<data>
99
10<record id="invoice_form" model="ir.ui.view">10<record id="invoice_form" model="ir.ui.view">
11 <field name="name">add.sdd.mandate.on.customer.invoice.form</field>11 <field name="name">add.dd.mandate.on.customer.invoice.form</field>
12 <field name="model">account.invoice</field>12 <field name="model">account.invoice</field>
13 <field name="inherit_id" ref="account.invoice_form"/>13 <field name="inherit_id" ref="account.invoice_form"/>
14 <field name="arch" type="xml">14 <field name="arch" type="xml">
15 <field name="partner_bank_id" position="after">15 <field name="partner_bank_id" position="after">
16 <field name="sdd_mandate_id" domain="[('partner_id', '=', partner_id), ('state', '=', 'valid')]" attrs="{'invisible': [('type', '=', 'out_refund')]}"/>16 <field name="mandate_id" domain="[('partner_id', '=', partner_id), ('state', '=', 'valid')]" attrs="{'invisible': [('type', '=', 'out_refund')]}"/>
17 </field>17 </field>
18 </field>18 </field>
19</record>19</record>
2020
=== renamed file 'account_banking_sepa_direct_debit/account_payment_view.xml' => 'account_banking_mandate/view/account_payment_view.xml'
--- account_banking_sepa_direct_debit/account_payment_view.xml 2013-11-11 10:56:49 +0000
+++ account_banking_mandate/view/account_payment_view.xml 2014-07-29 07:49:30 +0000
@@ -7,17 +7,17 @@
7<openerp>7<openerp>
8<data>8<data>
99
10<record id="sdd_view_payment_order_form" model="ir.ui.view">10<record id="dd_view_payment_order_form" model="ir.ui.view">
11 <field name="name">sdd.payment.order.form</field>11 <field name="name">dd.payment.order.form</field>
12 <field name="model">payment.order</field>12 <field name="model">payment.order</field>
13 <field name="inherit_id" ref="account_payment.view_payment_order_form"/>13 <field name="inherit_id" ref="account_payment.view_payment_order_form"/>
14 <field name="arch" type="xml">14 <field name="arch" type="xml">
15 <xpath expr="//field[@name='line_ids']/form/notebook/page/group/field[@name='bank_id']" position="after">15 <xpath expr="//field[@name='line_ids']/form/notebook/page/group/field[@name='bank_id']" position="after">
16 <field name="sdd_mandate_id" domain="[('partner_bank_id', '=', bank_id), ('state', '=', 'valid')]" invisible="context.get('default_payment_order_type')!='debit'" context="{'default_partner_bank_id': bank_id}"/>16 <field name="mandate_id" domain="[('partner_bank_id', '=', bank_id), ('state', '=', 'valid')]" invisible="context.get('default_payment_order_type')!='debit'" context="{'default_partner_bank_id': bank_id}"/>
17 <newline />17 <newline />
18 </xpath>18 </xpath>
19 <xpath expr="//field[@name='line_ids']/tree/field[@name='bank_id']" position="after">19 <xpath expr="//field[@name='line_ids']/tree/field[@name='bank_id']" position="after">
20 <field name="sdd_mandate_id" string="SDD Mandate" invisible="context.get('default_payment_order_type')!='debit'"/>20 <field name="mandate_id" string="DD Mandate" invisible="context.get('default_payment_order_type')!='debit'"/>
21 </xpath>21 </xpath>
22 </field>22 </field>
23</record>23</record>
2424
=== renamed file 'account_banking_sepa_direct_debit/res_partner_bank_view.xml' => 'account_banking_mandate/view/res_partner_bank_view.xml'
--- account_banking_sepa_direct_debit/res_partner_bank_view.xml 2013-11-11 10:56:49 +0000
+++ account_banking_mandate/view/res_partner_bank_view.xml 2014-07-29 07:49:30 +0000
@@ -7,39 +7,38 @@
7<openerp>7<openerp>
8<data>8<data>
99
10<record id="sdd_mandate_partner_bank_form" model="ir.ui.view">10<record id="dd_mandate_partner_bank_form" model="ir.ui.view">
11 <field name="name">sdd.mandate.res.partner.bank.form</field>11 <field name="name">dd.mandate.res.partner.bank.form</field>
12 <field name="model">res.partner.bank</field>12 <field name="model">res.partner.bank</field>
13 <field name="inherit_id" ref="base.view_partner_bank_form"/>13 <field name="inherit_id" ref="base.view_partner_bank_form"/>
14 <field name="arch" type="xml">14 <field name="arch" type="xml">
15 <group name="bank" position="after">15 <group name="bank" position="after">
16 <group name="sdd_mandates" string="SEPA Direct Debit Mandates" colspan="4">16 <group name="dd_mandates" string="Direct Debit Mandates" colspan="4">
17 <field name="sdd_mandate_ids" context="{'default_partner_bank_id': active_id, 'sdd_mandate_bank_partner_view': True}" nolabel="1"/>17 <field name="mandate_ids" context="{'default_partner_bank_id': active_id, 'dd_mandate_bank_partner_view': True}" nolabel="1"/>
18 </group>18 </group>
19 </group>19 </group>
20 </field>20 </field>
21</record>21</record>
2222
23<record id="sdd_mandate_partner_bank_tree" model="ir.ui.view">23<record id="dd_mandate_partner_bank_tree" model="ir.ui.view">
24 <field name="name">sdd.mandate.res.partner.bank.tree</field>24 <field name="name">dd.mandate.res.partner.bank.tree</field>
25 <field name="model">res.partner.bank</field>25 <field name="model">res.partner.bank</field>
26 <field name="inherit_id" ref="base.view_partner_bank_tree"/>26 <field name="inherit_id" ref="base.view_partner_bank_tree"/>
27 <field name="arch" type="xml">27 <field name="arch" type="xml">
28 <field name="partner_id" position="after">28 <field name="partner_id" position="after">
29 <field name="sdd_mandate_ids" string="SDD Mandates"/>29 <field name="mandate_ids" string="DD Mandates"/>
30 </field>30 </field>
31 </field>31 </field>
32</record>32</record>
3333
34<!-- add number of mandates in this list of bank accounts34<!-- add number of mandates in this list of bank accounts on the partner form -->
35on the partner form -->35<record id="dd_mandate_partner_form" model="ir.ui.view">
36<record id="sdd_mandate_partner_form" model="ir.ui.view">36 <field name="name">dd.mandate.partner.form</field>
37 <field name="name">sdd.mandate.partner.form</field>
38 <field name="model">res.partner</field>37 <field name="model">res.partner</field>
39 <field name="inherit_id" ref="account.view_partner_property_form"/>38 <field name="inherit_id" ref="account.view_partner_property_form"/>
40 <field name="arch" type="xml">39 <field name="arch" type="xml">
41 <xpath expr="//field[@name='bank_ids']/tree/field[@name='owner_name']" position="after">40 <xpath expr="//field[@name='bank_ids']/tree/field[@name='owner_name']" position="after">
42 <field name="sdd_mandate_ids" string="SDD Mandates"/>41 <field name="mandate_ids" string="DD Mandates"/>
43 </xpath>42 </xpath>
44 </field>43 </field>
45</record>44</record>
4645
=== modified file 'account_banking_payment_export/model/payment_order_create.py'
--- account_banking_payment_export/model/payment_order_create.py 2014-03-22 00:53:03 +0000
+++ account_banking_payment_export/model/payment_order_create.py 2014-07-29 07:49:30 +0000
@@ -26,6 +26,10 @@
26from openerp.osv import orm, fields26from openerp.osv import orm, fields
27from openerp.tools.translate import _27from openerp.tools.translate import _
2828
29import logging
30
31logger = logging.getLogger(__name__)
32
2933
30class payment_order_create(orm.TransientModel):34class payment_order_create(orm.TransientModel):
31 _inherit = 'payment.order.create'35 _inherit = 'payment.order.create'
@@ -48,6 +52,7 @@
48 mod_obj = self.pool.get('ir.model.data')52 mod_obj = self.pool.get('ir.model.data')
49 if context is None:53 if context is None:
50 context = {}54 context = {}
55
51 data = self.read(cr, uid, ids, ['duedate'], context=context)[0]56 data = self.read(cr, uid, ids, ['duedate'], context=context)[0]
52 search_due_date = data['duedate']57 search_due_date = data['duedate']
53 58
@@ -68,6 +73,7 @@
68 '|', ('date_maturity', '<=', search_due_date),73 '|', ('date_maturity', '<=', search_due_date),
69 ('date_maturity', '=', False)74 ('date_maturity', '=', False)
70 ]75 ]
76
71 line_ids = line_obj.search(cr, uid, domain, context=context)77 line_ids = line_obj.search(cr, uid, domain, context=context)
72 context.update({'line_ids': line_ids})78 context.update({'line_ids': line_ids})
73 model_data_ids = mod_obj.search(79 model_data_ids = mod_obj.search(
7480
=== modified file 'account_banking_sepa_direct_debit/__openerp__.py'
--- account_banking_sepa_direct_debit/__openerp__.py 2014-03-12 22:18:33 +0000
+++ account_banking_sepa_direct_debit/__openerp__.py 2014-07-29 07:49:30 +0000
@@ -27,7 +27,7 @@
27 'author': 'Akretion',27 'author': 'Akretion',
28 'website': 'http://www.akretion.com',28 'website': 'http://www.akretion.com',
29 'category': 'Banking addons',29 'category': 'Banking addons',
30 'depends': ['account_direct_debit', 'account_banking_pain_base'],30 'depends': ['account_banking_mandate', 'account_banking_pain_base', 'account_direct_debit'],
31 'external_dependencies': {31 'external_dependencies': {
32 'python': ['unidecode', 'lxml'],32 'python': ['unidecode', 'lxml'],
33 },33 },
@@ -35,14 +35,11 @@
35 'security/original_mandate_required_security.xml',35 'security/original_mandate_required_security.xml',
36 'account_banking_sdd_view.xml',36 'account_banking_sdd_view.xml',
37 'sdd_mandate_view.xml',37 'sdd_mandate_view.xml',
38 'res_partner_bank_view.xml',
39 'account_payment_view.xml',
40 'company_view.xml',38 'company_view.xml',
41 'mandate_expire_cron.xml',39 'mandate_expire_cron.xml',
42 'account_invoice_view.xml',
43 'wizard/export_sdd_view.xml',40 'wizard/export_sdd_view.xml',
44 'data/payment_type_sdd.xml',41 'data/payment_type_sdd.xml',
45 'data/mandate_reference_sequence.xml',42 'data/sdd_mandate_sequence.xml',
46 'security/ir.model.access.csv',43 'security/ir.model.access.csv',
47 ],44 ],
48 'demo': ['sepa_direct_debit_demo.xml'],45 'demo': ['sepa_direct_debit_demo.xml'],
4946
=== modified file 'account_banking_sepa_direct_debit/account_banking_sdd.py'
--- account_banking_sepa_direct_debit/account_banking_sdd.py 2014-06-23 09:47:01 +0000
+++ account_banking_sepa_direct_debit/account_banking_sdd.py 2014-07-29 07:49:30 +0000
@@ -32,7 +32,6 @@
3232
33logger = logging.getLogger(__name__)33logger = logging.getLogger(__name__)
3434
35
36class banking_export_sdd(orm.Model):35class banking_export_sdd(orm.Model):
37 '''SEPA Direct Debit export'''36 '''SEPA Direct Debit export'''
38 _name = 'banking.export.sdd'37 _name = 'banking.export.sdd'
@@ -100,23 +99,10 @@
10099
101class sdd_mandate(orm.Model):100class sdd_mandate(orm.Model):
102 '''SEPA Direct Debit Mandate'''101 '''SEPA Direct Debit Mandate'''
103 _name = 'sdd.mandate'
104 _description = __doc__102 _description = __doc__
105 _rec_name = 'unique_mandate_reference'103 _name = 'account.banking.mandate'
106 _inherit = ['mail.thread']104 _inherit = 'account.banking.mandate'
107 _order = 'signature_date desc'
108 _track = {105 _track = {
109 'state': {
110 'account_banking_sepa_direct_debit.mandate_valid':
111 lambda self, cr, uid, obj, ctx=None:
112 obj['state'] == 'valid',
113 'account_banking_sepa_direct_debit.mandate_expired':
114 lambda self, cr, uid, obj, ctx=None:
115 obj['state'] == 'expired',
116 'account_banking_sepa_direct_debit.mandate_cancel':
117 lambda self, cr, uid, obj, ctx=None:
118 obj['state'] == 'cancel',
119 },
120 'recurrent_sequence_type': {106 'recurrent_sequence_type': {
121 'account_banking_sepa_direct_debit.recurrent_sequence_type_first':107 'account_banking_sepa_direct_debit.recurrent_sequence_type_first':
122 lambda self, cr, uid, obj, ctx=None:108 lambda self, cr, uid, obj, ctx=None:
@@ -132,15 +118,6 @@
132 }118 }
133119
134 _columns = {120 _columns = {
135 'partner_bank_id': fields.many2one(
136 'res.partner.bank', 'Bank Account', track_visibility='onchange'),
137 'partner_id': fields.related(
138 'partner_bank_id', 'partner_id', type='many2one',
139 relation='res.partner', string='Partner', readonly=True),
140 'company_id': fields.many2one('res.company', 'Company', required=True),
141 'unique_mandate_reference': fields.char(
142 'Unique Mandate Reference', size=35, readonly=True,
143 track_visibility='always'),
144 'type': fields.selection([121 'type': fields.selection([
145 ('recurrent', 'Recurrent'),122 ('recurrent', 'Recurrent'),
146 ('oneoff', 'One-Off'),123 ('oneoff', 'One-Off'),
@@ -152,24 +129,6 @@
152 ], 'Sequence Type for Next Debit', track_visibility='onchange',129 ], 'Sequence Type for Next Debit', track_visibility='onchange',
153 help="This field is only used for Recurrent mandates, not for "130 help="This field is only used for Recurrent mandates, not for "
154 "One-Off mandates."),131 "One-Off mandates."),
155 'signature_date': fields.date(
156 'Date of Signature of the Mandate', track_visibility='onchange'),
157 'scan': fields.binary('Scan of the Mandate'),
158 'last_debit_date': fields.date(
159 'Date of the Last Debit', readonly=True),
160 'state': fields.selection([
161 ('draft', 'Draft'),
162 ('valid', 'Valid'),
163 ('expired', 'Expired'),
164 ('cancel', 'Cancelled'),
165 ], 'Status',
166 help="Only valid mandates can be used in a payment line. A "
167 "cancelled mandate is a mandate that has been cancelled by "
168 "the customer. A one-off mandate expires after its first use. "
169 "A recurrent mandate expires after it's final use or if it "
170 "hasn't been used for 36 months."),
171 'payment_line_ids': fields.one2many(
172 'payment.line', 'sdd_mandate_id', "Related Payment Lines"),
173 'sepa_migrated': fields.boolean(132 'sepa_migrated': fields.boolean(
174 'Migrated to SEPA', track_visibility='onchange',133 'Migrated to SEPA', track_visibility='onchange',
175 help="If this field is not active, the mandate section of the "134 help="If this field is not active, the mandate section of the "
@@ -188,57 +147,11 @@
188 }147 }
189148
190 _defaults = {149 _defaults = {
191 'company_id': lambda self, cr, uid, context:
192 self.pool['res.company']._company_default_get(
193 cr, uid, 'sdd.mandate', context=context),
194 'unique_mandate_reference': '/',
195 'state': 'draft',
196 'sepa_migrated': True,150 'sepa_migrated': True,
197 }151 }
198152
199 _sql_constraints = [(
200 'mandate_ref_company_uniq',
201 'unique(unique_mandate_reference, company_id)',
202 'A Mandate with the same reference already exists for this company !'
203 )]
204
205 def create(self, cr, uid, vals, context=None):
206 if vals.get('unique_mandate_reference', '/') == '/':
207 vals['unique_mandate_reference'] = \
208 self.pool['ir.sequence'].next_by_code(
209 cr, uid, 'sdd.mandate.reference', context=context)
210 return super(sdd_mandate, self).create(cr, uid, vals, context=context)
211
212 def _check_sdd_mandate(self, cr, uid, ids):153 def _check_sdd_mandate(self, cr, uid, ids):
213 for mandate in self.browse(cr, uid, ids):154 for mandate in self.browse(cr, uid, ids):
214 if (mandate.signature_date and
215 mandate.signature_date >
216 datetime.today().strftime('%Y-%m-%d')):
217 raise orm.except_orm(
218 _('Error:'),
219 _("The date of signature of mandate '%s' is in the "
220 "future !")
221 % mandate.unique_mandate_reference)
222 if mandate.state == 'valid' and not mandate.signature_date:
223 raise orm.except_orm(
224 _('Error:'),
225 _("Cannot validate the mandate '%s' without a date of "
226 "signature.")
227 % mandate.unique_mandate_reference)
228 if mandate.state == 'valid' and not mandate.partner_bank_id:
229 raise orm.except_orm(
230 _('Error:'),
231 _("Cannot validate the mandate '%s' because it is not "
232 "attached to a bank account.")
233 % mandate.unique_mandate_reference)
234
235 if (mandate.signature_date and mandate.last_debit_date and
236 mandate.signature_date > mandate.last_debit_date):
237 raise orm.except_orm(
238 _('Error:'),
239 _("The mandate '%s' can't have a date of last debit "
240 "before the date of signature.")
241 % mandate.unique_mandate_reference)
242 if (mandate.type == 'recurrent'155 if (mandate.type == 'recurrent'
243 and not mandate.recurrent_sequence_type):156 and not mandate.recurrent_sequence_type):
244 raise orm.except_orm(157 raise orm.except_orm(
@@ -265,11 +178,18 @@
265178
266 _constraints = [179 _constraints = [
267 (_check_sdd_mandate, "Error msg in raise", [180 (_check_sdd_mandate, "Error msg in raise", [
268 'last_debit_date', 'signature_date', 'state', 'partner_bank_id',
269 'type', 'recurrent_sequence_type', 'sepa_migrated',181 'type', 'recurrent_sequence_type', 'sepa_migrated',
270 'original_mandate_identification',182 'original_mandate_identification',
271 ]),183 ]),
272 ]184 ]
185
186 def create(self, cr, uid, vals, context=None):
187 if vals.get('unique_mandate_reference', '/') == '/':
188 sequence = self.pool['ir.sequence']
189 next_value = sequence.next_by_code(cr, uid, 'sdd.mandate.reference', context=context)
190 vals['unique_mandate_reference'] = next_value
191
192 return super(sdd_mandate, self).create(cr, uid, vals, context=context)
273193
274 def mandate_type_change(self, cr, uid, ids, type):194 def mandate_type_change(self, cr, uid, ids, type):
275 if type == 'recurrent':195 if type == 'recurrent':
@@ -282,12 +202,8 @@
282 def mandate_partner_bank_change(202 def mandate_partner_bank_change(
283 self, cr, uid, ids, partner_bank_id, type, recurrent_sequence_type,203 self, cr, uid, ids, partner_bank_id, type, recurrent_sequence_type,
284 last_debit_date, state):204 last_debit_date, state):
285 res = {'value': {}}205 res = super(sdd_mandate, self).mandate_partner_bank_change(cr, uid,
286 if partner_bank_id:206 ids, partner_bank_id, last_debit_date, state)
287 partner_bank_read = self.pool['res.partner.bank'].read(
288 cr, uid, partner_bank_id, ['partner_id'])['partner_id']
289 if partner_bank_read:
290 res['value']['partner_id'] = partner_bank_read[0]
291 if (state == 'valid' and partner_bank_id207 if (state == 'valid' and partner_bank_id
292 and type == 'recurrent'208 and type == 'recurrent'
293 and recurrent_sequence_type != 'first'):209 and recurrent_sequence_type != 'first'):
@@ -301,35 +217,6 @@
301 }217 }
302 return res218 return res
303219
304 def validate(self, cr, uid, ids, context=None):
305 to_validate_ids = []
306 for mandate in self.browse(cr, uid, ids, context=context):
307 assert mandate.state == 'draft', 'Mandate should be in draft state'
308 to_validate_ids.append(mandate.id)
309 self.write(
310 cr, uid, to_validate_ids, {'state': 'valid'}, context=context)
311 return True
312
313 def cancel(self, cr, uid, ids, context=None):
314 to_cancel_ids = []
315 for mandate in self.browse(cr, uid, ids, context=context):
316 assert mandate.state in ('draft', 'valid'),\
317 'Mandate should be in draft or valid state'
318 to_cancel_ids.append(mandate.id)
319 self.write(
320 cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context)
321 return True
322
323 def back2draft(self, cr, uid, ids, context=None):
324 to_draft_ids = []
325 for mandate in self.browse(cr, uid, ids, context=context):
326 assert mandate.state == 'cancel',\
327 'Mandate should be in cancel state'
328 to_draft_ids.append(mandate.id)
329 self.write(
330 cr, uid, to_draft_ids, {'state': 'draft'}, context=context)
331 return True
332
333 def _sdd_mandate_set_state_to_expired(self, cr, uid, context=None):220 def _sdd_mandate_set_state_to_expired(self, cr, uid, context=None):
334 logger.info('Searching for SDD Mandates that must be set to Expired')221 logger.info('Searching for SDD Mandates that must be set to Expired')
335 expire_limit_date = datetime.today() + \222 expire_limit_date = datetime.today() + \
@@ -351,90 +238,4 @@
351 % expired_mandate_ids)238 % expired_mandate_ids)
352 else:239 else:
353 logger.info('0 SDD Mandates must be set to Expired')240 logger.info('0 SDD Mandates must be set to Expired')
354 return True241 return True
355
356
357class res_partner_bank(orm.Model):
358 _inherit = 'res.partner.bank'
359
360 _columns = {
361 'sdd_mandate_ids': fields.one2many(
362 'sdd.mandate', 'partner_bank_id', 'SEPA Direct Debit Mandates'),
363 }
364
365
366class payment_line(orm.Model):
367 _inherit = 'payment.line'
368
369 _columns = {
370 'sdd_mandate_id': fields.many2one(
371 'sdd.mandate', 'SEPA Direct Debit Mandate',
372 domain=[('state', '=', 'valid')]),
373 }
374
375 def create(self, cr, uid, vals, context=None):
376 '''If the customer invoice has a mandate, take it
377 otherwise, take the first valid mandate of the bank account'''
378 if context is None:
379 context = {}
380 if not vals:
381 vals = {}
382 partner_bank_id = vals.get('bank_id')
383 move_line_id = vals.get('move_line_id')
384 if (context.get('default_payment_order_type') == 'debit'
385 and 'sdd_mandate_id' not in vals):
386 if move_line_id:
387 line = self.pool['account.move.line'].browse(
388 cr, uid, move_line_id, context=context)
389 if (line.invoice and line.invoice.type == 'out_invoice'
390 and line.invoice.sdd_mandate_id):
391 vals.update({
392 'sdd_mandate_id': line.invoice.sdd_mandate_id.id,
393 'bank_id':
394 line.invoice.sdd_mandate_id.partner_bank_id.id,
395 })
396 if partner_bank_id and 'sdd_mandate_id' not in vals:
397 mandate_ids = self.pool['sdd.mandate'].search(cr, uid, [
398 ('partner_bank_id', '=', partner_bank_id),
399 ('state', '=', 'valid'),
400 ], context=context)
401 if mandate_ids:
402 vals['sdd_mandate_id'] = mandate_ids[0]
403 return super(payment_line, self).create(cr, uid, vals, context=context)
404
405 def _check_mandate_bank_link(self, cr, uid, ids):
406 for payline in self.browse(cr, uid, ids):
407 if (payline.sdd_mandate_id and payline.bank_id
408 and payline.sdd_mandate_id.partner_bank_id.id !=
409 payline.bank_id.id):
410 raise orm.except_orm(
411 _('Error:'),
412 _("The payment line with reference '%s' has the bank "
413 "account '%s' which is not attached to the mandate "
414 "'%s' (this mandate is attached to the bank account "
415 "'%s').") % (
416 payline.name,
417 self.pool['res.partner.bank'].name_get(
418 cr, uid, [payline.bank_id.id])[0][1],
419 payline.sdd_mandate_id.unique_mandate_reference,
420 self.pool['res.partner.bank'].name_get(
421 cr, uid,
422 [payline.sdd_mandate_id.partner_bank_id.id])[0][1],
423 ))
424 return True
425
426 _constraints = [
427 (_check_mandate_bank_link, 'Error msg in raise',
428 ['sdd_mandate_id', 'bank_id']),
429 ]
430
431
432class account_invoice(orm.Model):
433 _inherit = 'account.invoice'
434
435 _columns = {
436 'sdd_mandate_id': fields.many2one(
437 'sdd.mandate', 'SEPA Direct Debit Mandate',
438 domain=[('state', '=', 'valid')], readonly=True,
439 states={'draft': [('readonly', False)]})
440 }
441\ No newline at end of file242\ No newline at end of file
442243
=== added file 'account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml'
--- account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml 1970-01-01 00:00:00 +0000
+++ account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml 2014-07-29 07:49:30 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3<data noupdate="1">
4 <record id="sdd_mandate_seq_type" model="ir.sequence.type">
5 <field name="name">SDD Mandate Reference</field>
6 <field name="code">sdd.mandate.reference</field>
7 </record>
8
9 <record id="sdd_mandate_seq" model="ir.sequence">
10 <field name="name">SDD Mandate Reference</field>
11 <field name="code">sdd.mandate.reference</field>
12 <field name="prefix">RUM</field>
13 <field name="padding" eval="7"/>
14 <!-- remember that max size for the mandate ref is 35 -->
15 </record>
16</data>
17</openerp>
018
=== modified file 'account_banking_sepa_direct_debit/mandate_expire_cron.xml'
--- account_banking_sepa_direct_debit/mandate_expire_cron.xml 2013-11-07 22:22:19 +0000
+++ account_banking_sepa_direct_debit/mandate_expire_cron.xml 2014-07-29 07:49:30 +0000
@@ -17,7 +17,7 @@
17 <field name="interval_type">days</field>17 <field name="interval_type">days</field>
18 <field name="numbercall">-1</field> <!-- don't limit the number of calls -->18 <field name="numbercall">-1</field> <!-- don't limit the number of calls -->
19 <field name="doall" eval="False"/>19 <field name="doall" eval="False"/>
20 <field name="model" eval="'sdd.mandate'"/>20 <field name="model" eval="'account.banking.mandate'"/>
21 <field name="function" eval="'_sdd_mandate_set_state_to_expired'" />21 <field name="function" eval="'_sdd_mandate_set_state_to_expired'" />
22 <field name="args" eval="'()'"/>22 <field name="args" eval="'()'"/>
23</record>23</record>
2424
=== added file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml'
--- account_banking_sepa_direct_debit/sdd_mandate_view.xml 1970-01-01 00:00:00 +0000
+++ account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-07-29 07:49:30 +0000
@@ -0,0 +1,133 @@
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3 Copyright (C) 2013 Akretion (http://www.akretion.com)
4 @author: Alexis de Lattre <alexis.delattre@akretion.com>
5 The licence is in the file __openerp__.py
6-->
7<!--
8 Customize all mandate views (and actions) to fit SEPA mandate style
9-->
10<openerp>
11<data>
12 <record id="sdd_mandate_form" model="ir.ui.view">
13 <field name="name">sdd.mandate.form</field>
14 <field name="model">account.banking.mandate</field>
15 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_form"/>
16 <field name="arch" type="xml">
17 <data>
18 <xpath expr="//field[@name='partner_id']" position="after">
19 <field name="type" on_change="mandate_type_change(type)"/>
20 <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/>
21 </xpath>
22 <xpath expr="//field[@name='partner_bank_id']" position="attributes">
23 <attribute name="on_change">mandate_partner_bank_change(partner_bank_id, type, recurrent_sequence_type, last_debit_date, state)</attribute>
24 </xpath>
25 <xpath expr="//field[@name='last_debit_date']" position="after">
26 <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
27 <field name="original_mandate_identification" attrs="{'invisible': [('sepa_migrated', '=', True)], 'required': [('sepa_migrated', '=', False)]}" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/>
28 </xpath>
29 </data>
30 </field>
31 </record>
32
33 <record id="sdd_mandate_tree" model="ir.ui.view">
34 <field name="name">sdd.mandate.tree</field>
35 <field name="model">account.banking.mandate</field>
36 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_tree"/>
37 <field name="arch" type="xml">
38 <data>
39 <xpath expr="//field[@name='unique_mandate_reference']" position="after">
40 <field name="type" string="Type"/>
41 </xpath>
42 </data>
43 </field>
44 </record>
45
46 <record id="sdd_mandate_search" model="ir.ui.view">
47 <field name="name">sdd.mandate.search</field>
48 <field name="model">account.banking.mandate</field>
49 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_search"/>
50 <field name="arch" type="xml">
51 <xpath expr="//filter[@name='expired']" position="after">
52 <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" />
53 <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" />
54 </xpath>
55 </field>
56 </record>
57
58 <record id="dd_mandate_action" model="ir.actions.act_window">
59 <field name="name">SEPA Direct Debit Mandates</field>
60 <field name="res_model">account.banking.mandate</field>
61 <field name="view_type">form</field>
62 <field name="view_mode">tree,form</field>
63 <field name="help" type="html">
64 <p class="oe_view_nocontent_create">
65 Click to create a new SEPA Direct Debit Mandate.
66 </p><p>
67 A SEPA Direct Debit Mandate is a document signed by your customer that gives you the autorization to do one or several direct debits on his bank account.
68 </p>
69 </field>
70 </record>
71
72 <menuitem id="account_banking_mandate.dd_mandate_menu"
73 parent="account_payment.menu_main_payment"
74 action="dd_mandate_action"
75 sequence="40"
76 />
77
78 <record id="sdd_mandate_partner_bank_form" model="ir.ui.view">
79 <field name="name">sdd.mandate.res.partner.bank.form</field>
80 <field name="model">res.partner.bank</field>
81 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_form"/>
82 <field name="arch" type="xml">
83 <xpath expr="//group[@name='dd_mandates']" position="attributes">
84 <attribute name="string">SEPA Direct Debit Mandates</attribute>
85 </xpath>
86 </field>
87 </record>
88
89 <record id="sdd_mandate_partner_bank_tree" model="ir.ui.view">
90 <field name="name">sdd.mandate.res.partner.bank.tree</field>
91 <field name="model">res.partner.bank</field>
92 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_tree"/>
93 <field name="arch" type="xml">
94 <xpath expr="//field[@name='mandate_ids']" position="attributes">
95 <attribute name="string">SDD Mandates</attribute>
96 </xpath>
97 </field>
98 </record>
99
100 <record id="sdd_mandate_partner_form" model="ir.ui.view">
101 <field name="name">sdd.mandate.partner.form</field>
102 <field name="model">res.partner</field>
103 <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_form"/>
104 <field name="arch" type="xml">
105 <xpath expr="//field[@name='bank_ids']/tree/field[@name='mandate_ids']" position="attributes">
106 <attribute name="string">SDD Mandates</attribute>
107 </xpath>
108 </field>
109 </record>
110
111 <!-- notifications in the chatter -->
112 <record id="recurrent_sequence_type_first" model="mail.message.subtype">
113 <field name="name">Sequence Type set to First</field>
114 <field name="res_model">account.banking.mandate</field>
115 <field name="default" eval="False"/>
116 <field name="description">Sequence Type set to First</field>
117 </record>
118
119 <record id="recurrent_sequence_type_recurring" model="mail.message.subtype">
120 <field name="name">Sequence Type set to Recurring</field>
121 <field name="res_model">account.banking.mandate</field>
122 <field name="default" eval="False"/>
123 <field name="description">Sequence Type set to Recurring</field>
124 </record>
125
126 <record id="recurrent_sequence_type_final" model="mail.message.subtype">
127 <field name="name">Sequence Type set to Final</field>
128 <field name="res_model">account.banking.mandate</field>
129 <field name="default" eval="False"/>
130 <field name="description">Sequence Type set to Final</field>
131 </record>
132</data>
133</openerp>
0134
=== modified file 'account_banking_sepa_direct_debit/security/ir.model.access.csv'
--- account_banking_sepa_direct_debit/security/ir.model.access.csv 2013-10-15 21:29:28 +0000
+++ account_banking_sepa_direct_debit/security/ir.model.access.csv 2014-07-29 07:49:30 +0000
@@ -1,4 +1,4 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_banking_export_sdd","Full access on banking.export.sdd","model_banking_export_sdd","account_payment.group_account_payment",1,1,1,12"access_banking_export_sdd","Full access on banking.export.sdd","model_banking_export_sdd","account_payment.group_account_payment",1,1,1,1
3"access_sdd_mandate","Full access on sdd.mandate","model_sdd_mandate","account_payment.group_account_payment",1,1,1,13"access_sdd_mandate","Full access on sdd.mandate","model_account_banking_mandate","account_payment.group_account_payment",1,1,1,1
4"access_sdd_mandate_read","Read access on sdd.mandate","model_sdd_mandate","base.group_user",1,0,0,04"access_sdd_mandate_read","Read access on sdd.mandate","model_account_banking_mandate","base.group_user",1,0,0,0
55
=== modified file 'account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml'
--- account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-02-16 14:01:09 +0000
+++ account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-07-29 07:49:30 +0000
@@ -15,7 +15,7 @@
15 <field name="sepa_creditor_identifier">FR78ZZZ424242</field>15 <field name="sepa_creditor_identifier">FR78ZZZ424242</field>
16</record>16</record>
1717
18<record id="res_partner_12_mandate" model="sdd.mandate">18<record id="res_partner_12_mandate" model="account.banking.mandate">
19 <field name="partner_bank_id" ref="account_banking_payment_export.res_partner_12_iban"/>19 <field name="partner_bank_id" ref="account_banking_payment_export.res_partner_12_iban"/>
20 <field name="type">recurrent</field>20 <field name="type">recurrent</field>
21 <field name="recurrent_sequence_type">first</field>21 <field name="recurrent_sequence_type">first</field>
2222
=== modified file 'account_banking_sepa_direct_debit/wizard/export_sdd.py'
--- account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-01-05 23:51:22 +0000
+++ account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-07-29 07:49:30 +0000
@@ -93,7 +93,7 @@
93 previous_bank = False93 previous_bank = False
94 payline_ids = payline_obj.search(94 payline_ids = payline_obj.search(
95 cr, uid, [95 cr, uid, [
96 ('sdd_mandate_id', '=', payline.sdd_mandate_id.id),96 ('mandate_id', '=', payline.mandate_id.id),
97 ('bank_id', '!=', payline.bank_id.id),97 ('bank_id', '!=', payline.bank_id.id),
98 ],98 ],
99 context=context)99 context=context)
@@ -188,22 +188,22 @@
188 requested_date = payment_order.date_scheduled or today188 requested_date = payment_order.date_scheduled or today
189 else:189 else:
190 requested_date = today190 requested_date = today
191 if not line.sdd_mandate_id:191 if not line.mandate_id:
192 raise orm.except_orm(192 raise orm.except_orm(
193 _('Error:'),193 _('Error:'),
194 _("Missing SEPA Direct Debit mandate on the payment "194 _("Missing SEPA Direct Debit mandate on the payment "
195 "line with partner '%s' and Invoice ref '%s'.")195 "line with partner '%s' and Invoice ref '%s'.")
196 % (line.partner_id.name,196 % (line.partner_id.name,
197 line.ml_inv_ref.number))197 line.ml_inv_ref.number))
198 if line.sdd_mandate_id.state != 'valid':198 if line.mandate_id.state != 'valid':
199 raise orm.except_orm(199 raise orm.except_orm(
200 _('Error:'),200 _('Error:'),
201 _("The SEPA Direct Debit mandate with reference '%s' "201 _("The SEPA Direct Debit mandate with reference '%s' "
202 "for partner '%s' has expired.")202 "for partner '%s' has expired.")
203 % (line.sdd_mandate_id.unique_mandate_reference,203 % (line.mandate_id.unique_mandate_reference,
204 line.sdd_mandate_id.partner_id.name))204 line.mandate_id.partner_id.name))
205 if line.sdd_mandate_id.type == 'oneoff':205 if line.mandate_id.type == 'oneoff':
206 if not line.sdd_mandate_id.last_debit_date:206 if not line.mandate_id.last_debit_date:
207 seq_type = 'OOFF'207 seq_type = 'OOFF'
208 else:208 else:
209 raise orm.except_orm(209 raise orm.except_orm(
@@ -212,17 +212,17 @@
212 "'%s' has type set to 'One-Off' and it has a "212 "'%s' has type set to 'One-Off' and it has a "
213 "last debit date set to '%s', so we can't use "213 "last debit date set to '%s', so we can't use "
214 "it.")214 "it.")
215 % (line.sdd_mandate_id.unique_mandate_reference,215 % (line.mandate_id.unique_mandate_reference,
216 line.sdd_mandate_id.partner_id.name,216 line.mandate_id.partner_id.name,
217 line.sdd_mandate_id.last_debit_date))217 line.mandate_id.last_debit_date))
218 elif line.sdd_mandate_id.type == 'recurrent':218 elif line.mandate_id.type == 'recurrent':
219 seq_type_map = {219 seq_type_map = {
220 'recurring': 'RCUR',220 'recurring': 'RCUR',
221 'first': 'FRST',221 'first': 'FRST',
222 'final': 'FNAL',222 'final': 'FNAL',
223 }223 }
224 seq_type_label = \224 seq_type_label = \
225 line.sdd_mandate_id.recurrent_sequence_type225 line.mandate_id.recurrent_sequence_type
226 assert seq_type_label is not False226 assert seq_type_label is not False
227 seq_type = seq_type_map[seq_type_label]227 seq_type = seq_type_map[seq_type_label]
228228
@@ -306,22 +306,22 @@
306 mandate_related_info_2_47, 'MndtId')306 mandate_related_info_2_47, 'MndtId')
307 mandate_identification_2_48.text = self._prepare_field(307 mandate_identification_2_48.text = self._prepare_field(
308 cr, uid, 'Unique Mandate Reference',308 cr, uid, 'Unique Mandate Reference',
309 'line.sdd_mandate_id.unique_mandate_reference',309 'line.mandate_id.unique_mandate_reference',
310 {'line': line}, 35,310 {'line': line}, 35,
311 gen_args=gen_args, context=context)311 gen_args=gen_args, context=context)
312 mandate_signature_date_2_49 = etree.SubElement(312 mandate_signature_date_2_49 = etree.SubElement(
313 mandate_related_info_2_47, 'DtOfSgntr')313 mandate_related_info_2_47, 'DtOfSgntr')
314 mandate_signature_date_2_49.text = self._prepare_field(314 mandate_signature_date_2_49.text = self._prepare_field(
315 cr, uid, 'Mandate Signature Date',315 cr, uid, 'Mandate Signature Date',
316 'line.sdd_mandate_id.signature_date',316 'line.mandate_id.signature_date',
317 {'line': line}, 10,317 {'line': line}, 10,
318 gen_args=gen_args, context=context)318 gen_args=gen_args, context=context)
319 if sequence_type == 'FRST' and (319 if sequence_type == 'FRST' and (
320 line.sdd_mandate_id.last_debit_date or320 line.mandate_id.last_debit_date or
321 not line.sdd_mandate_id.sepa_migrated):321 not line.mandate_id.sepa_migrated):
322 previous_bank = self._get_previous_bank(322 previous_bank = self._get_previous_bank(
323 cr, uid, line, context=context)323 cr, uid, line, context=context)
324 if previous_bank or not line.sdd_mandate_id.sepa_migrated:324 if previous_bank or not line.mandate_id.sepa_migrated:
325 amendment_indicator_2_50 = etree.SubElement(325 amendment_indicator_2_50 = etree.SubElement(
326 mandate_related_info_2_47, 'AmdmntInd')326 mandate_related_info_2_47, 'AmdmntInd')
327 amendment_indicator_2_50.text = 'true'327 amendment_indicator_2_50.text = 'true'
@@ -362,13 +362,13 @@
362 ori_debtor_agent_other, 'Id')362 ori_debtor_agent_other, 'Id')
363 ori_debtor_agent_other_id.text = 'SMNDA'363 ori_debtor_agent_other_id.text = 'SMNDA'
364 # SMNDA = Same Mandate New Debtor Agent364 # SMNDA = Same Mandate New Debtor Agent
365 elif not line.sdd_mandate_id.sepa_migrated:365 elif not line.mandate_id.sepa_migrated:
366 ori_mandate_identification_2_52 = etree.SubElement(366 ori_mandate_identification_2_52 = etree.SubElement(
367 amendment_info_details_2_51, 'OrgnlMndtId')367 amendment_info_details_2_51, 'OrgnlMndtId')
368 ori_mandate_identification_2_52.text = \368 ori_mandate_identification_2_52.text = \
369 self._prepare_field(369 self._prepare_field(
370 cr, uid, 'Original Mandate Identification',370 cr, uid, 'Original Mandate Identification',
371 'line.sdd_mandate_id.'371 'line.mandate_id.'
372 'original_mandate_identification',372 'original_mandate_identification',
373 {'line': line},373 {'line': line},
374 gen_args=gen_args,374 gen_args=gen_args,
@@ -425,25 +425,25 @@
425 wf_service = netsvc.LocalService('workflow')425 wf_service = netsvc.LocalService('workflow')
426 for order in sepa_export.payment_order_ids:426 for order in sepa_export.payment_order_ids:
427 wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)427 wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr)
428 mandate_ids = [line.sdd_mandate_id.id for line in order.line_ids]428 mandate_ids = [line.mandate_id.id for line in order.line_ids]
429 self.pool['sdd.mandate'].write(429 self.pool['account.banking.mandate'].write(
430 cr, uid, mandate_ids,430 cr, uid, mandate_ids,
431 {'last_debit_date': datetime.today().strftime('%Y-%m-%d')},431 {'last_debit_date': datetime.today().strftime('%Y-%m-%d')},
432 context=context)432 context=context)
433 to_expire_ids = []433 to_expire_ids = []
434 first_mandate_ids = []434 first_mandate_ids = []
435 for line in order.line_ids:435 for line in order.line_ids:
436 if line.sdd_mandate_id.type == 'oneoff':436 if line.mandate_id.type == 'oneoff':
437 to_expire_ids.append(line.sdd_mandate_id.id)437 to_expire_ids.append(line.mandate_id.id)
438 elif line.sdd_mandate_id.type == 'recurrent':438 elif line.mandate_id.type == 'recurrent':
439 seq_type = line.sdd_mandate_id.recurrent_sequence_type439 seq_type = line.mandate_id.recurrent_sequence_type
440 if seq_type == 'final':440 if seq_type == 'final':
441 to_expire_ids.append(line.sdd_mandate_id.id)441 to_expire_ids.append(line.mandate_id.id)
442 elif seq_type == 'first':442 elif seq_type == 'first':
443 first_mandate_ids.append(line.sdd_mandate_id.id)443 first_mandate_ids.append(line.mandate_id.id)
444 self.pool['sdd.mandate'].write(444 self.pool['account.banking.mandate'].write(
445 cr, uid, to_expire_ids, {'state': 'expired'}, context=context)445 cr, uid, to_expire_ids, {'state': 'expired'}, context=context)
446 self.pool['sdd.mandate'].write(446 self.pool['account.banking.mandate'].write(
447 cr, uid, first_mandate_ids, {447 cr, uid, first_mandate_ids, {
448 'recurrent_sequence_type': 'recurring',448 'recurrent_sequence_type': 'recurring',
449 'sepa_migrated': True,449 'sepa_migrated': True,

Subscribers

People subscribed via source and target branches

to status/vote changes: