Merge lp:~compassion/banking-addons/banking-addons-mandate into lp:banking-addons
- banking-addons-mandate
- Merge into banking-addons-70
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 |
Related bugs: |
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 |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : | # |
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
1 | === added directory 'account_banking_mandate' | |||
2 | === added file 'account_banking_mandate/__init__.py' | |||
3 | --- account_banking_mandate/__init__.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ account_banking_mandate/__init__.py 2014-07-29 07:49:30 +0000 | |||
5 | @@ -0,0 +1,22 @@ | |||
6 | 1 | # -*- encoding: utf-8 -*- | ||
7 | 2 | ############################################################################## | ||
8 | 3 | # | ||
9 | 4 | # Mandate module for openERP | ||
10 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
11 | 6 | # @author: Cyril Sester <csester@compassion.ch> | ||
12 | 7 | # | ||
13 | 8 | # This program is free software: you can redistribute it and/or modify | ||
14 | 9 | # it under the terms of the GNU Affero General Public License as | ||
15 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
16 | 11 | # License, or (at your option) any later version. | ||
17 | 12 | # | ||
18 | 13 | # This program is distributed in the hope that it will be useful, | ||
19 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | 16 | # GNU Affero General Public License for more details. | ||
22 | 17 | # | ||
23 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
24 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | 20 | # | ||
26 | 21 | ############################################################################## | ||
27 | 22 | import model | ||
28 | 0 | \ No newline at end of file | 23 | \ No newline at end of file |
29 | 1 | 24 | ||
30 | === added file 'account_banking_mandate/__openerp__.py' | |||
31 | --- account_banking_mandate/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
32 | +++ account_banking_mandate/__openerp__.py 2014-07-29 07:49:30 +0000 | |||
33 | @@ -0,0 +1,46 @@ | |||
34 | 1 | # -*- encoding: utf-8 -*- | ||
35 | 2 | ############################################################################## | ||
36 | 3 | # | ||
37 | 4 | # Mandate module for openERP | ||
38 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
39 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
40 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
41 | 8 | # | ||
42 | 9 | # This program is free software: you can redistribute it and/or modify | ||
43 | 10 | # it under the terms of the GNU Affero General Public License as | ||
44 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
45 | 12 | # License, or (at your option) any later version. | ||
46 | 13 | # | ||
47 | 14 | # This program is distributed in the hope that it will be useful, | ||
48 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
49 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
50 | 17 | # GNU Affero General Public License for more details. | ||
51 | 18 | # | ||
52 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
53 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
54 | 21 | # | ||
55 | 22 | ############################################################################## | ||
56 | 23 | { | ||
57 | 24 | 'name': 'Account Banking Mandate', | ||
58 | 25 | 'summary': 'Direct Debit mandate', | ||
59 | 26 | 'version': '0.1', | ||
60 | 27 | 'license': 'AGPL-3', | ||
61 | 28 | 'author': 'Compassion CH', | ||
62 | 29 | 'website': 'http://www.compassion.ch', | ||
63 | 30 | 'category': 'Banking addons', | ||
64 | 31 | 'depends': ['account_payment'], | ||
65 | 32 | 'external_dependencies': {}, | ||
66 | 33 | 'data': [ | ||
67 | 34 | 'view/account_banking_mandate_view.xml', | ||
68 | 35 | 'view/account_invoice_view.xml', | ||
69 | 36 | 'view/account_payment_view.xml', | ||
70 | 37 | 'view/res_partner_bank_view.xml', | ||
71 | 38 | 'data/mandate_reference_sequence.xml', | ||
72 | 39 | ], | ||
73 | 40 | 'demo': [], | ||
74 | 41 | 'description': '''This module adds a generic model for banking mandates. These mandates can be specialized to | ||
75 | 42 | fit any banking mandates (such as sepa or lsv). | ||
76 | 43 | ''', | ||
77 | 44 | 'active': False, | ||
78 | 45 | 'installable': True, | ||
79 | 46 | } | ||
80 | 0 | 47 | ||
81 | === added directory 'account_banking_mandate/data' | |||
82 | === renamed file 'account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml' => 'account_banking_mandate/data/mandate_reference_sequence.xml' | |||
83 | --- account_banking_sepa_direct_debit/data/mandate_reference_sequence.xml 2013-10-22 22:25:06 +0000 | |||
84 | +++ account_banking_mandate/data/mandate_reference_sequence.xml 2014-07-29 07:49:30 +0000 | |||
85 | @@ -3,14 +3,14 @@ | |||
86 | 3 | <data noupdate="1"> | 3 | <data noupdate="1"> |
87 | 4 | 4 | ||
88 | 5 | 5 | ||
92 | 6 | <record id="sdd_mandate_seq_type" model="ir.sequence.type"> | 6 | <record id="dd_mandate_seq_type" model="ir.sequence.type"> |
93 | 7 | <field name="name">SDD Mandate Reference</field> | 7 | <field name="name">DD Mandate Reference</field> |
94 | 8 | <field name="code">sdd.mandate.reference</field> | 8 | <field name="code">account.banking.mandate</field> |
95 | 9 | </record> | 9 | </record> |
96 | 10 | 10 | ||
100 | 11 | <record id="sdd_mandate_seq" model="ir.sequence"> | 11 | <record id="dd_mandate_seq" model="ir.sequence"> |
101 | 12 | <field name="name">SDD Mandate Reference</field> | 12 | <field name="name">DD Mandate Reference</field> |
102 | 13 | <field name="code">sdd.mandate.reference</field> | 13 | <field name="code">account.banking.mandate</field> |
103 | 14 | <field name="prefix">RUM</field> | 14 | <field name="prefix">RUM</field> |
104 | 15 | <field name="padding" eval="7"/> | 15 | <field name="padding" eval="7"/> |
105 | 16 | <!-- remember that max size for the mandate ref is 35 --> | 16 | <!-- remember that max size for the mandate ref is 35 --> |
106 | 17 | 17 | ||
107 | === added directory 'account_banking_mandate/model' | |||
108 | === added file 'account_banking_mandate/model/__init__.py' | |||
109 | --- account_banking_mandate/model/__init__.py 1970-01-01 00:00:00 +0000 | |||
110 | +++ account_banking_mandate/model/__init__.py 2014-07-29 07:49:30 +0000 | |||
111 | @@ -0,0 +1,26 @@ | |||
112 | 1 | # -*- encoding: utf-8 -*- | ||
113 | 2 | ############################################################################## | ||
114 | 3 | # | ||
115 | 4 | # Mandate module for openERP | ||
116 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
117 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
118 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
119 | 8 | # | ||
120 | 9 | # This program is free software: you can redistribute it and/or modify | ||
121 | 10 | # it under the terms of the GNU Affero General Public License as | ||
122 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
123 | 12 | # License, or (at your option) any later version. | ||
124 | 13 | # | ||
125 | 14 | # This program is distributed in the hope that it will be useful, | ||
126 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
127 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
128 | 17 | # GNU Affero General Public License for more details. | ||
129 | 18 | # | ||
130 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
131 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
132 | 21 | # | ||
133 | 22 | ############################################################################## | ||
134 | 23 | from . import account_banking_mandate | ||
135 | 24 | from . import account_invoice | ||
136 | 25 | from . import partner_bank | ||
137 | 26 | from . import payment_line | ||
138 | 0 | \ No newline at end of file | 27 | \ No newline at end of file |
139 | 1 | 28 | ||
140 | === added file 'account_banking_mandate/model/account_banking_mandate.py' | |||
141 | --- account_banking_mandate/model/account_banking_mandate.py 1970-01-01 00:00:00 +0000 | |||
142 | +++ account_banking_mandate/model/account_banking_mandate.py 2014-07-29 07:49:30 +0000 | |||
143 | @@ -0,0 +1,185 @@ | |||
144 | 1 | # -*- encoding: utf-8 -*- | ||
145 | 2 | ############################################################################## | ||
146 | 3 | # | ||
147 | 4 | # Mandate module for openERP | ||
148 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
149 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
150 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
151 | 8 | # | ||
152 | 9 | # This program is free software: you can redistribute it and/or modify | ||
153 | 10 | # it under the terms of the GNU Affero General Public License as | ||
154 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
155 | 12 | # License, or (at your option) any later version. | ||
156 | 13 | # | ||
157 | 14 | # This program is distributed in the hope that it will be useful, | ||
158 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
159 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
160 | 17 | # GNU Affero General Public License for more details. | ||
161 | 18 | # | ||
162 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
163 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
164 | 21 | # | ||
165 | 22 | ############################################################################## | ||
166 | 23 | |||
167 | 24 | from datetime import datetime | ||
168 | 25 | import logging | ||
169 | 26 | from openerp.osv import orm, fields | ||
170 | 27 | from openerp.tools.translate import _ | ||
171 | 28 | |||
172 | 29 | logger = logging.getLogger(__name__) | ||
173 | 30 | |||
174 | 31 | class mandate(orm.Model): | ||
175 | 32 | ''' The banking mandate is attached to a bank account and represents an | ||
176 | 33 | authorization that the bank account owner gives to a company for a specific operation | ||
177 | 34 | (such as direct debit) | ||
178 | 35 | ''' | ||
179 | 36 | _name = 'account.banking.mandate' | ||
180 | 37 | _description = "A generic banking mandate" | ||
181 | 38 | _rec_name = 'unique_mandate_reference' | ||
182 | 39 | _inherit = ['mail.thread'] | ||
183 | 40 | _order = 'signature_date desc' | ||
184 | 41 | _track = { | ||
185 | 42 | 'state': { | ||
186 | 43 | 'account_banking_mandate.mandate_valid': | ||
187 | 44 | lambda self, cr, uid, obj, ctx=None: | ||
188 | 45 | obj['state'] == 'valid', | ||
189 | 46 | 'account_banking_mandate.mandate_expired': | ||
190 | 47 | lambda self, cr, uid, obj, ctx=None: | ||
191 | 48 | obj['state'] == 'expired', | ||
192 | 49 | 'account_banking_mandate.mandate_cancel': | ||
193 | 50 | lambda self, cr, uid, obj, ctx=None: | ||
194 | 51 | obj['state'] == 'cancel', | ||
195 | 52 | }, | ||
196 | 53 | } | ||
197 | 54 | |||
198 | 55 | def _get_states(self, cr, uid, context=None): | ||
199 | 56 | return ( | ||
200 | 57 | ('draft', 'Draft'), | ||
201 | 58 | ('valid', 'Valid'), | ||
202 | 59 | ('expired', 'Expired'), | ||
203 | 60 | ('cancel', 'Cancelled'),) | ||
204 | 61 | |||
205 | 62 | _columns = { | ||
206 | 63 | 'partner_bank_id': fields.many2one( | ||
207 | 64 | 'res.partner.bank', 'Bank Account', track_visibility='onchange'), | ||
208 | 65 | 'partner_id': fields.related( | ||
209 | 66 | 'partner_bank_id', 'partner_id', type='many2one', | ||
210 | 67 | relation='res.partner', string='Partner', readonly=True), | ||
211 | 68 | 'company_id': fields.many2one('res.company', 'Company', required=True), | ||
212 | 69 | 'unique_mandate_reference': fields.char( | ||
213 | 70 | 'Unique Mandate Reference', size=35, readonly=True, | ||
214 | 71 | track_visibility='always'), | ||
215 | 72 | 'signature_date': fields.date( | ||
216 | 73 | 'Date of Signature of the Mandate', track_visibility='onchange'), | ||
217 | 74 | 'scan': fields.binary('Scan of the Mandate'), | ||
218 | 75 | 'last_debit_date': fields.date( | ||
219 | 76 | 'Date of the Last Debit', readonly=True), | ||
220 | 77 | 'state': fields.selection(_get_states, 'Status', | ||
221 | 78 | help="Only valid mandates can be used in a payment line. A " | ||
222 | 79 | "cancelled mandate is a mandate that has been cancelled by " | ||
223 | 80 | "the customer. "), | ||
224 | 81 | 'payment_line_ids': fields.one2many( | ||
225 | 82 | 'payment.line', 'mandate_id', "Related Payment Lines"), | ||
226 | 83 | } | ||
227 | 84 | |||
228 | 85 | _defaults = { | ||
229 | 86 | 'company_id': lambda self, cr, uid, context: | ||
230 | 87 | self.pool['res.company']._company_default_get( | ||
231 | 88 | cr, uid, 'account.banking.mandate', context=context), | ||
232 | 89 | 'state': 'draft', | ||
233 | 90 | 'unique_mandate_reference': '/', | ||
234 | 91 | } | ||
235 | 92 | |||
236 | 93 | _sql_constraints = [( | ||
237 | 94 | 'mandate_ref_company_uniq', | ||
238 | 95 | 'unique(unique_mandate_reference, company_id)', | ||
239 | 96 | 'A Mandate with the same reference already exists for this company !' | ||
240 | 97 | )] | ||
241 | 98 | |||
242 | 99 | def create(self, cr, uid, vals, context=None): | ||
243 | 100 | if vals.get('unique_mandate_reference', '/') == '/': | ||
244 | 101 | sequence = self.pool['ir.sequence'] | ||
245 | 102 | next_value = sequence.next_by_code(cr, uid, 'account.banking.mandate', context=context) | ||
246 | 103 | vals['unique_mandate_reference'] = next_value | ||
247 | 104 | |||
248 | 105 | return super(mandate, self).create(cr, uid, vals, context=context) | ||
249 | 106 | |||
250 | 107 | def _check_dates(self, cr, uid, ids): | ||
251 | 108 | for mandate in self.browse(cr, uid, ids): | ||
252 | 109 | if (mandate.signature_date and | ||
253 | 110 | mandate.signature_date > | ||
254 | 111 | datetime.today().strftime('%Y-%m-%d')): | ||
255 | 112 | raise orm.except_orm( | ||
256 | 113 | _('Error:'), | ||
257 | 114 | _("The date of signature of mandate '%s' is in the " | ||
258 | 115 | "future !") | ||
259 | 116 | % mandate.unique_mandate_reference) | ||
260 | 117 | |||
261 | 118 | if (mandate.signature_date and mandate.last_debit_date and | ||
262 | 119 | mandate.signature_date > mandate.last_debit_date): | ||
263 | 120 | raise orm.except_orm( | ||
264 | 121 | _('Error:'), | ||
265 | 122 | _("The mandate '%s' can't have a date of last debit " | ||
266 | 123 | "before the date of signature.") | ||
267 | 124 | % mandate.unique_mandate_reference) | ||
268 | 125 | return True | ||
269 | 126 | |||
270 | 127 | def _check_valid_state(self, cr, uid, ids): | ||
271 | 128 | for mandate in self.browse(cr, uid, ids): | ||
272 | 129 | if mandate.state == 'valid' and not mandate.signature_date: | ||
273 | 130 | raise orm.except_orm( | ||
274 | 131 | _('Error:'), | ||
275 | 132 | _("Cannot validate the mandate '%s' without a date of " | ||
276 | 133 | "signature.") | ||
277 | 134 | % mandate.unique_mandate_reference) | ||
278 | 135 | if mandate.state == 'valid' and not mandate.partner_bank_id: | ||
279 | 136 | raise orm.except_orm( | ||
280 | 137 | _('Error:'), | ||
281 | 138 | _("Cannot validate the mandate '%s' because it is not " | ||
282 | 139 | "attached to a bank account.") | ||
283 | 140 | % mandate.unique_mandate_reference) | ||
284 | 141 | return True | ||
285 | 142 | |||
286 | 143 | _constraints = [ | ||
287 | 144 | (_check_dates, "Error msg in raise", ['signature_date', 'last_debit_date']), | ||
288 | 145 | (_check_valid_state, "Error msg in raise", ['state', 'partner_bank_id']), | ||
289 | 146 | ] | ||
290 | 147 | |||
291 | 148 | def mandate_partner_bank_change( | ||
292 | 149 | self, cr, uid, ids, partner_bank_id, last_debit_date, state, context=None): | ||
293 | 150 | res = {'value': {}} | ||
294 | 151 | if partner_bank_id: | ||
295 | 152 | partner_bank_read = self.pool['res.partner.bank'].read( | ||
296 | 153 | cr, uid, partner_bank_id, ['partner_id'])['partner_id'] | ||
297 | 154 | if partner_bank_read: | ||
298 | 155 | res['value']['partner_id'] = partner_bank_read[0] | ||
299 | 156 | return res | ||
300 | 157 | |||
301 | 158 | def validate(self, cr, uid, ids, context=None): | ||
302 | 159 | to_validate_ids = [] | ||
303 | 160 | for mandate in self.browse(cr, uid, ids, context=context): | ||
304 | 161 | assert mandate.state == 'draft', 'Mandate should be in draft state' | ||
305 | 162 | to_validate_ids.append(mandate.id) | ||
306 | 163 | self.write( | ||
307 | 164 | cr, uid, to_validate_ids, {'state': 'valid'}, context=context) | ||
308 | 165 | return True | ||
309 | 166 | |||
310 | 167 | def cancel(self, cr, uid, ids, context=None): | ||
311 | 168 | to_cancel_ids = [] | ||
312 | 169 | for mandate in self.browse(cr, uid, ids, context=context): | ||
313 | 170 | assert mandate.state in ('draft', 'valid'),\ | ||
314 | 171 | 'Mandate should be in draft or valid state' | ||
315 | 172 | to_cancel_ids.append(mandate.id) | ||
316 | 173 | self.write( | ||
317 | 174 | cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context) | ||
318 | 175 | return True | ||
319 | 176 | |||
320 | 177 | def back2draft(self, cr, uid, ids, context=None): | ||
321 | 178 | to_draft_ids = [] | ||
322 | 179 | for mandate in self.browse(cr, uid, ids, context=context): | ||
323 | 180 | assert mandate.state == 'cancel',\ | ||
324 | 181 | 'Mandate should be in cancel state' | ||
325 | 182 | to_draft_ids.append(mandate.id) | ||
326 | 183 | self.write( | ||
327 | 184 | cr, uid, to_draft_ids, {'state': 'draft'}, context=context) | ||
328 | 185 | return True | ||
329 | 0 | \ No newline at end of file | 186 | \ No newline at end of file |
330 | 1 | 187 | ||
331 | === added file 'account_banking_mandate/model/account_invoice.py' | |||
332 | --- account_banking_mandate/model/account_invoice.py 1970-01-01 00:00:00 +0000 | |||
333 | +++ account_banking_mandate/model/account_invoice.py 2014-07-29 07:49:30 +0000 | |||
334 | @@ -0,0 +1,34 @@ | |||
335 | 1 | # -*- encoding: utf-8 -*- | ||
336 | 2 | ############################################################################## | ||
337 | 3 | # | ||
338 | 4 | # Mandate module for openERP | ||
339 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
340 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
341 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
342 | 8 | # | ||
343 | 9 | # This program is free software: you can redistribute it and/or modify | ||
344 | 10 | # it under the terms of the GNU Affero General Public License as | ||
345 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
346 | 12 | # License, or (at your option) any later version. | ||
347 | 13 | # | ||
348 | 14 | # This program is distributed in the hope that it will be useful, | ||
349 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
350 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
351 | 17 | # GNU Affero General Public License for more details. | ||
352 | 18 | # | ||
353 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
354 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
355 | 21 | # | ||
356 | 22 | ############################################################################## | ||
357 | 23 | |||
358 | 24 | from openerp.osv import orm, fields | ||
359 | 25 | |||
360 | 26 | class account_invoice(orm.Model): | ||
361 | 27 | _inherit = 'account.invoice' | ||
362 | 28 | |||
363 | 29 | _columns = { | ||
364 | 30 | 'mandate_id': fields.many2one( | ||
365 | 31 | 'account.banking.mandate', 'Direct Debit Mandate', | ||
366 | 32 | domain=[('state', '=', 'valid')], readonly=True, | ||
367 | 33 | states={'draft': [('readonly', False)]}) | ||
368 | 34 | } | ||
369 | 0 | \ No newline at end of file | 35 | \ No newline at end of file |
370 | 1 | 36 | ||
371 | === added file 'account_banking_mandate/model/partner_bank.py' | |||
372 | --- account_banking_mandate/model/partner_bank.py 1970-01-01 00:00:00 +0000 | |||
373 | +++ account_banking_mandate/model/partner_bank.py 2014-07-29 07:49:30 +0000 | |||
374 | @@ -0,0 +1,33 @@ | |||
375 | 1 | # -*- encoding: utf-8 -*- | ||
376 | 2 | ############################################################################## | ||
377 | 3 | # | ||
378 | 4 | # Mandate module for openERP | ||
379 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
380 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
381 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
382 | 8 | # | ||
383 | 9 | # This program is free software: you can redistribute it and/or modify | ||
384 | 10 | # it under the terms of the GNU Affero General Public License as | ||
385 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
386 | 12 | # License, or (at your option) any later version. | ||
387 | 13 | # | ||
388 | 14 | # This program is distributed in the hope that it will be useful, | ||
389 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
390 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
391 | 17 | # GNU Affero General Public License for more details. | ||
392 | 18 | # | ||
393 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
394 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
395 | 21 | # | ||
396 | 22 | ############################################################################## | ||
397 | 23 | |||
398 | 24 | from openerp.osv import orm, fields | ||
399 | 25 | |||
400 | 26 | class res_partner_bank(orm.Model): | ||
401 | 27 | _inherit = 'res.partner.bank' | ||
402 | 28 | |||
403 | 29 | #Add mandate references on bank account (a bank account can have several mandates) | ||
404 | 30 | _columns = { | ||
405 | 31 | 'mandate_ids': fields.one2many( | ||
406 | 32 | 'account.banking.mandate', 'partner_bank_id', 'Banking Mandates'), | ||
407 | 33 | } | ||
408 | 0 | \ No newline at end of file | 34 | \ No newline at end of file |
409 | 1 | 35 | ||
410 | === added file 'account_banking_mandate/model/payment_line.py' | |||
411 | --- account_banking_mandate/model/payment_line.py 1970-01-01 00:00:00 +0000 | |||
412 | +++ account_banking_mandate/model/payment_line.py 2014-07-29 07:49:30 +0000 | |||
413 | @@ -0,0 +1,100 @@ | |||
414 | 1 | # -*- encoding: utf-8 -*- | ||
415 | 2 | ############################################################################## | ||
416 | 3 | # | ||
417 | 4 | # Mandate module for openERP | ||
418 | 5 | # Copyright (C) 2014 Compassion CH (http://www.compassion.ch) | ||
419 | 6 | # @author: Cyril Sester <csester@compassion.ch>, | ||
420 | 7 | # Alexis de Lattre <alexis.delattre@akretion.com> | ||
421 | 8 | # | ||
422 | 9 | # This program is free software: you can redistribute it and/or modify | ||
423 | 10 | # it under the terms of the GNU Affero General Public License as | ||
424 | 11 | # published by the Free Software Foundation, either version 3 of the | ||
425 | 12 | # License, or (at your option) any later version. | ||
426 | 13 | # | ||
427 | 14 | # This program is distributed in the hope that it will be useful, | ||
428 | 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
429 | 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
430 | 17 | # GNU Affero General Public License for more details. | ||
431 | 18 | # | ||
432 | 19 | # You should have received a copy of the GNU Affero General Public License | ||
433 | 20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
434 | 21 | # | ||
435 | 22 | ############################################################################## | ||
436 | 23 | |||
437 | 24 | from openerp.osv import orm, fields | ||
438 | 25 | |||
439 | 26 | import logging | ||
440 | 27 | |||
441 | 28 | logger = logging.getLogger(__name__) | ||
442 | 29 | |||
443 | 30 | class payment_line(orm.Model): | ||
444 | 31 | _inherit = 'payment.line' | ||
445 | 32 | |||
446 | 33 | #Add mandate reference on payment line (several payment line can referer to same mandate) | ||
447 | 34 | _columns = { | ||
448 | 35 | 'mandate_id': fields.many2one( | ||
449 | 36 | 'account.banking.mandate', 'Direct Debit Mandate', | ||
450 | 37 | domain=[('state', '=', 'valid')]), | ||
451 | 38 | } | ||
452 | 39 | |||
453 | 40 | def create(self, cr, uid, vals, context=None): | ||
454 | 41 | '''If the customer invoice has a mandate, take it | ||
455 | 42 | otherwise, take the first valid mandate of the bank account. | ||
456 | 43 | This is done here and not in _defaults because we need the context. | ||
457 | 44 | ''' | ||
458 | 45 | if context is None: | ||
459 | 46 | context = {} | ||
460 | 47 | if not vals: | ||
461 | 48 | vals = {} | ||
462 | 49 | partner_bank_id = vals.get('bank_id') | ||
463 | 50 | move_line_id = vals.get('move_line_id') | ||
464 | 51 | logger.info("partner_bank_id: %s" % partner_bank_id) | ||
465 | 52 | logger.info("move_line_id: %s" % move_line_id) | ||
466 | 53 | logger.info("context: %s" % context) | ||
467 | 54 | logger.info("vals : %s" % vals) | ||
468 | 55 | if (context.get('search_payment_order_type') == 'debit' | ||
469 | 56 | and 'mandate_id' not in vals): | ||
470 | 57 | if move_line_id: | ||
471 | 58 | line = self.pool['account.move.line'].browse( | ||
472 | 59 | cr, uid, move_line_id, context=context) | ||
473 | 60 | if (line.invoice and line.invoice.type == 'out_invoice' | ||
474 | 61 | and line.invoice.mandate_id): | ||
475 | 62 | vals.update({ | ||
476 | 63 | 'mandate_id': line.invoice.mandate_id.id, | ||
477 | 64 | 'bank_id': | ||
478 | 65 | line.invoice.mandate_id.partner_bank_id.id, | ||
479 | 66 | }) | ||
480 | 67 | if partner_bank_id and 'mandate_id' not in vals: | ||
481 | 68 | mandate_ids = self.pool['account.banking.mandate'].search(cr, uid, [ | ||
482 | 69 | ('partner_bank_id', '=', partner_bank_id), | ||
483 | 70 | ('state', '=', 'valid'), | ||
484 | 71 | ], context=context) | ||
485 | 72 | if mandate_ids: | ||
486 | 73 | vals['mandate_id'] = mandate_ids[0] | ||
487 | 74 | return super(payment_line, self).create(cr, uid, vals, context=context) | ||
488 | 75 | |||
489 | 76 | def _check_mandate_bank_link(self, cr, uid, ids): | ||
490 | 77 | for payline in self.browse(cr, uid, ids): | ||
491 | 78 | if (payline.mandate_id and payline.bank_id | ||
492 | 79 | and payline.mandate_id.partner_bank_id.id != | ||
493 | 80 | payline.bank_id.id): | ||
494 | 81 | raise orm.except_orm( | ||
495 | 82 | _('Error:'), | ||
496 | 83 | _("The payment line with reference '%s' has the bank " | ||
497 | 84 | "account '%s' which is not attached to the mandate " | ||
498 | 85 | "'%s' (this mandate is attached to the bank account " | ||
499 | 86 | "'%s').") % ( | ||
500 | 87 | payline.name, | ||
501 | 88 | self.pool['res.partner.bank'].name_get( | ||
502 | 89 | cr, uid, [payline.bank_id.id])[0][1], | ||
503 | 90 | payline.mandate_id.unique_mandate_reference, | ||
504 | 91 | self.pool['res.partner.bank'].name_get( | ||
505 | 92 | cr, uid, | ||
506 | 93 | [payline.mandate_id.partner_bank_id.id])[0][1], | ||
507 | 94 | )) | ||
508 | 95 | return True | ||
509 | 96 | |||
510 | 97 | _constraints = [ | ||
511 | 98 | (_check_mandate_bank_link, 'Error msg in raise', | ||
512 | 99 | ['mandate_id', 'bank_id']), | ||
513 | 100 | ] | ||
514 | 0 | \ No newline at end of file | 101 | \ No newline at end of file |
515 | 1 | 102 | ||
516 | === added directory 'account_banking_mandate/view' | |||
517 | === renamed file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml' => 'account_banking_mandate/view/account_banking_mandate_view.xml' | |||
518 | --- account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-06-11 22:03:21 +0000 | |||
519 | +++ account_banking_mandate/view/account_banking_mandate_view.xml 2014-07-29 07:49:30 +0000 | |||
520 | @@ -7,11 +7,11 @@ | |||
521 | 7 | <openerp> | 7 | <openerp> |
522 | 8 | <data> | 8 | <data> |
523 | 9 | 9 | ||
527 | 10 | <record id="sdd_mandate_form" model="ir.ui.view"> | 10 | <record id="dd_mandate_form" model="ir.ui.view"> |
528 | 11 | <field name="name">sdd.mandate.form</field> | 11 | <field name="name">dd.mandate.form</field> |
529 | 12 | <field name="model">sdd.mandate</field> | 12 | <field name="model">account.banking.mandate</field> |
530 | 13 | <field name="arch" type="xml"> | 13 | <field name="arch" type="xml"> |
532 | 14 | <form string="SEPA Direct Debit Mandate" version="7.0"> | 14 | <form string="Banking Mandate" version="7.0"> |
533 | 15 | <header> | 15 | <header> |
534 | 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"/> |
535 | 17 | <button name="cancel" type="object" string="Cancel" states="draft,valid"/> | 17 | <button name="cancel" type="object" string="Cancel" states="draft,valid"/> |
536 | @@ -29,17 +29,13 @@ | |||
537 | 29 | <group name="main"> | 29 | <group name="main"> |
538 | 30 | <field name="company_id" groups="base.group_multi_company"/> | 30 | <field name="company_id" groups="base.group_multi_company"/> |
539 | 31 | <field name="partner_bank_id" | 31 | <field name="partner_bank_id" |
542 | 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)" |
543 | 33 | invisible="context.get('sdd_mandate_bank_partner_view')" | 33 | invisible="context.get('dd_mandate_bank_partner_view')" |
544 | 34 | /> | 34 | /> |
548 | 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')"/> |
546 | 36 | <field name="type" on_change="mandate_type_change(type)"/> | ||
547 | 37 | <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/> | ||
549 | 38 | <field name="signature_date"/> | 36 | <field name="signature_date"/> |
550 | 39 | <field name="scan"/> | 37 | <field name="scan"/> |
551 | 40 | <field name="last_debit_date"/> | 38 | <field name="last_debit_date"/> |
552 | 41 | <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/> | ||
553 | 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"/> | ||
554 | 43 | </group> | 39 | </group> |
555 | 44 | <group name="payment_lines" string="Related Payment Lines"> | 40 | <group name="payment_lines" string="Related Payment Lines"> |
556 | 45 | <field name="payment_line_ids" nolabel="1"/> | 41 | <field name="payment_line_ids" nolabel="1"/> |
557 | @@ -53,15 +49,14 @@ | |||
558 | 53 | </field> | 49 | </field> |
559 | 54 | </record> | 50 | </record> |
560 | 55 | 51 | ||
564 | 56 | <record id="sdd_mandate_tree" model="ir.ui.view"> | 52 | <record id="dd_mandate_tree" model="ir.ui.view"> |
565 | 57 | <field name="name">sdd.mandate.tree</field> | 53 | <field name="name">dd.mandate.tree</field> |
566 | 58 | <field name="model">sdd.mandate</field> | 54 | <field name="model">account.banking.mandate</field> |
567 | 59 | <field name="arch" type="xml"> | 55 | <field name="arch" type="xml"> |
569 | 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')"> |
570 | 61 | <field name="company_id" groups="base.group_multi_company"/> | 57 | <field name="company_id" groups="base.group_multi_company"/> |
572 | 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')"/> |
573 | 63 | <field name="unique_mandate_reference" string="Reference"/> | 59 | <field name="unique_mandate_reference" string="Reference"/> |
574 | 64 | <field name="type" string="Type"/> | ||
575 | 65 | <field name="signature_date" string="Signature Date"/> | 60 | <field name="signature_date" string="Signature Date"/> |
576 | 66 | <field name="last_debit_date"/> | 61 | <field name="last_debit_date"/> |
577 | 67 | <field name="state"/> | 62 | <field name="state"/> |
578 | @@ -69,83 +64,60 @@ | |||
579 | 69 | </field> | 64 | </field> |
580 | 70 | </record> | 65 | </record> |
581 | 71 | 66 | ||
585 | 72 | <record id="sdd_mandate_search" model="ir.ui.view"> | 67 | <record id="dd_mandate_search" model="ir.ui.view"> |
586 | 73 | <field name="name">sdd.mandate.search</field> | 68 | <field name="name">dd.mandate.search</field> |
587 | 74 | <field name="model">sdd.mandate</field> | 69 | <field name="model">account.banking.mandate</field> |
588 | 75 | <field name="arch" type="xml"> | 70 | <field name="arch" type="xml"> |
590 | 76 | <search string="Search SEPA Direct Debit Mandates"> | 71 | <search string="Search Banking Mandates"> |
591 | 77 | <field name="partner_id"/> | 72 | <field name="partner_id"/> |
592 | 78 | <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" /> | 73 | <filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" /> |
593 | 79 | <filter name="valid" string="Valid" domain="[('state', '=', 'valid')]" /> | 74 | <filter name="valid" string="Valid" domain="[('state', '=', 'valid')]" /> |
594 | 80 | <filter name="cancel" string="Cancelled" domain="[('state', '=', 'cancel')]" /> | 75 | <filter name="cancel" string="Cancelled" domain="[('state', '=', 'cancel')]" /> |
595 | 81 | <filter name="expired" string="Expired" domain="[('state', '=', 'expired')]" /> | 76 | <filter name="expired" string="Expired" domain="[('state', '=', 'expired')]" /> |
596 | 82 | <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" /> | ||
597 | 83 | <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" /> | ||
598 | 84 | </search> | 77 | </search> |
599 | 85 | </field> | 78 | </field> |
600 | 86 | </record> | 79 | </record> |
601 | 87 | 80 | ||
605 | 88 | <record id="sdd_mandate_action" model="ir.actions.act_window"> | 81 | <record id="dd_mandate_action" model="ir.actions.act_window"> |
606 | 89 | <field name="name">SEPA Direct Debit Mandates</field> | 82 | <field name="name">Banking Mandates</field> |
607 | 90 | <field name="res_model">sdd.mandate</field> | 83 | <field name="res_model">account.banking.mandate</field> |
608 | 91 | <field name="view_type">form</field> | 84 | <field name="view_type">form</field> |
609 | 92 | <field name="view_mode">tree,form</field> | 85 | <field name="view_mode">tree,form</field> |
610 | 93 | <field name="help" type="html"> | 86 | <field name="help" type="html"> |
611 | 94 | <p class="oe_view_nocontent_create"> | 87 | <p class="oe_view_nocontent_create"> |
613 | 95 | Click to create a new SEPA Direct Debit Mandate. | 88 | Click to create a new Banking Mandate. |
614 | 96 | </p><p> | 89 | </p><p> |
616 | 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. |
617 | 98 | </p> | 91 | </p> |
618 | 99 | </field> | 92 | </field> |
619 | 100 | </record> | 93 | </record> |
620 | 101 | 94 | ||
622 | 102 | <menuitem id="sdd_mandate_menu" | 95 | <menuitem id="dd_mandate_menu" |
623 | 103 | parent="account_payment.menu_main_payment" | 96 | parent="account_payment.menu_main_payment" |
625 | 104 | action="sdd_mandate_action" | 97 | action="dd_mandate_action" |
626 | 105 | sequence="20" | 98 | sequence="20" |
627 | 106 | /> | 99 | /> |
628 | 107 | 100 | ||
630 | 108 | <!-- notifications in the chatter --> | 101 | <!-- notifications statuses in the chatter --> |
631 | 109 | <record id="mandate_valid" model="mail.message.subtype"> | 102 | <record id="mandate_valid" model="mail.message.subtype"> |
632 | 110 | <field name="name">Mandate Validated</field> | 103 | <field name="name">Mandate Validated</field> |
634 | 111 | <field name="res_model">sdd.mandate</field> | 104 | <field name="res_model">account.banking.mandate</field> |
635 | 112 | <field name="default" eval="False"/> | 105 | <field name="default" eval="False"/> |
637 | 113 | <field name="description">SEPA Direct Debit Mandate Validated</field> | 106 | <field name="description">Direct Debit Mandate Validated</field> |
638 | 114 | </record> | 107 | </record> |
639 | 115 | 108 | ||
640 | 116 | <record id="mandate_expired" model="mail.message.subtype"> | 109 | <record id="mandate_expired" model="mail.message.subtype"> |
641 | 117 | <field name="name">Mandate Expired</field> | 110 | <field name="name">Mandate Expired</field> |
643 | 118 | <field name="res_model">sdd.mandate</field> | 111 | <field name="res_model">account.banking.mandate</field> |
644 | 119 | <field name="default" eval="False"/> | 112 | <field name="default" eval="False"/> |
646 | 120 | <field name="description">SEPA Direct Debit Mandate has Expired</field> | 113 | <field name="description">Direct Debit Mandate has Expired</field> |
647 | 121 | </record> | 114 | </record> |
648 | 122 | 115 | ||
649 | 123 | <record id="mandate_cancel" model="mail.message.subtype"> | 116 | <record id="mandate_cancel" model="mail.message.subtype"> |
650 | 124 | <field name="name">Mandate Cancelled</field> | 117 | <field name="name">Mandate Cancelled</field> |
675 | 125 | <field name="res_model">sdd.mandate</field> | 118 | <field name="res_model">account.banking.mandate</field> |
676 | 126 | <field name="default" eval="False"/> | 119 | <field name="default" eval="False"/> |
677 | 127 | <field name="description">SEPA Direct Debit Mandate Cancelled</field> | 120 | <field name="description">Direct Debit Mandate Cancelled</field> |
654 | 128 | </record> | ||
655 | 129 | |||
656 | 130 | <record id="recurrent_sequence_type_first" model="mail.message.subtype"> | ||
657 | 131 | <field name="name">Sequence Type set to First</field> | ||
658 | 132 | <field name="res_model">sdd.mandate</field> | ||
659 | 133 | <field name="default" eval="False"/> | ||
660 | 134 | <field name="description">Sequence Type set to First</field> | ||
661 | 135 | </record> | ||
662 | 136 | |||
663 | 137 | <record id="recurrent_sequence_type_recurring" model="mail.message.subtype"> | ||
664 | 138 | <field name="name">Sequence Type set to Recurring</field> | ||
665 | 139 | <field name="res_model">sdd.mandate</field> | ||
666 | 140 | <field name="default" eval="False"/> | ||
667 | 141 | <field name="description">Sequence Type set to Recurring</field> | ||
668 | 142 | </record> | ||
669 | 143 | |||
670 | 144 | <record id="recurrent_sequence_type_final" model="mail.message.subtype"> | ||
671 | 145 | <field name="name">Sequence Type set to Final</field> | ||
672 | 146 | <field name="res_model">sdd.mandate</field> | ||
673 | 147 | <field name="default" eval="False"/> | ||
674 | 148 | <field name="description">Sequence Type set to Final</field> | ||
678 | 149 | </record> | 121 | </record> |
679 | 150 | 122 | ||
680 | 151 | </data> | 123 | </data> |
681 | 152 | 124 | ||
682 | === renamed file 'account_banking_sepa_direct_debit/account_invoice_view.xml' => 'account_banking_mandate/view/account_invoice_view.xml' | |||
683 | --- account_banking_sepa_direct_debit/account_invoice_view.xml 2013-11-09 14:05:07 +0000 | |||
684 | +++ account_banking_mandate/view/account_invoice_view.xml 2014-07-29 07:49:30 +0000 | |||
685 | @@ -8,12 +8,12 @@ | |||
686 | 8 | <data> | 8 | <data> |
687 | 9 | 9 | ||
688 | 10 | <record id="invoice_form" model="ir.ui.view"> | 10 | <record id="invoice_form" model="ir.ui.view"> |
690 | 11 | <field name="name">add.sdd.mandate.on.customer.invoice.form</field> | 11 | <field name="name">add.dd.mandate.on.customer.invoice.form</field> |
691 | 12 | <field name="model">account.invoice</field> | 12 | <field name="model">account.invoice</field> |
692 | 13 | <field name="inherit_id" ref="account.invoice_form"/> | 13 | <field name="inherit_id" ref="account.invoice_form"/> |
693 | 14 | <field name="arch" type="xml"> | 14 | <field name="arch" type="xml"> |
694 | 15 | <field name="partner_bank_id" position="after"> | 15 | <field name="partner_bank_id" position="after"> |
696 | 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')]}"/> |
697 | 17 | </field> | 17 | </field> |
698 | 18 | </field> | 18 | </field> |
699 | 19 | </record> | 19 | </record> |
700 | 20 | 20 | ||
701 | === renamed file 'account_banking_sepa_direct_debit/account_payment_view.xml' => 'account_banking_mandate/view/account_payment_view.xml' | |||
702 | --- account_banking_sepa_direct_debit/account_payment_view.xml 2013-11-11 10:56:49 +0000 | |||
703 | +++ account_banking_mandate/view/account_payment_view.xml 2014-07-29 07:49:30 +0000 | |||
704 | @@ -7,17 +7,17 @@ | |||
705 | 7 | <openerp> | 7 | <openerp> |
706 | 8 | <data> | 8 | <data> |
707 | 9 | 9 | ||
710 | 10 | <record id="sdd_view_payment_order_form" model="ir.ui.view"> | 10 | <record id="dd_view_payment_order_form" model="ir.ui.view"> |
711 | 11 | <field name="name">sdd.payment.order.form</field> | 11 | <field name="name">dd.payment.order.form</field> |
712 | 12 | <field name="model">payment.order</field> | 12 | <field name="model">payment.order</field> |
713 | 13 | <field name="inherit_id" ref="account_payment.view_payment_order_form"/> | 13 | <field name="inherit_id" ref="account_payment.view_payment_order_form"/> |
714 | 14 | <field name="arch" type="xml"> | 14 | <field name="arch" type="xml"> |
715 | 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"> |
717 | 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}"/> |
718 | 17 | <newline /> | 17 | <newline /> |
719 | 18 | </xpath> | 18 | </xpath> |
720 | 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"> |
722 | 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'"/> |
723 | 21 | </xpath> | 21 | </xpath> |
724 | 22 | </field> | 22 | </field> |
725 | 23 | </record> | 23 | </record> |
726 | 24 | 24 | ||
727 | === renamed file 'account_banking_sepa_direct_debit/res_partner_bank_view.xml' => 'account_banking_mandate/view/res_partner_bank_view.xml' | |||
728 | --- account_banking_sepa_direct_debit/res_partner_bank_view.xml 2013-11-11 10:56:49 +0000 | |||
729 | +++ account_banking_mandate/view/res_partner_bank_view.xml 2014-07-29 07:49:30 +0000 | |||
730 | @@ -7,39 +7,38 @@ | |||
731 | 7 | <openerp> | 7 | <openerp> |
732 | 8 | <data> | 8 | <data> |
733 | 9 | 9 | ||
736 | 10 | <record id="sdd_mandate_partner_bank_form" model="ir.ui.view"> | 10 | <record id="dd_mandate_partner_bank_form" model="ir.ui.view"> |
737 | 11 | <field name="name">sdd.mandate.res.partner.bank.form</field> | 11 | <field name="name">dd.mandate.res.partner.bank.form</field> |
738 | 12 | <field name="model">res.partner.bank</field> | 12 | <field name="model">res.partner.bank</field> |
739 | 13 | <field name="inherit_id" ref="base.view_partner_bank_form"/> | 13 | <field name="inherit_id" ref="base.view_partner_bank_form"/> |
740 | 14 | <field name="arch" type="xml"> | 14 | <field name="arch" type="xml"> |
741 | 15 | <group name="bank" position="after"> | 15 | <group name="bank" position="after"> |
744 | 16 | <group name="sdd_mandates" string="SEPA Direct Debit Mandates" colspan="4"> | 16 | <group name="dd_mandates" string="Direct Debit Mandates" colspan="4"> |
745 | 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"/> |
746 | 18 | </group> | 18 | </group> |
747 | 19 | </group> | 19 | </group> |
748 | 20 | </field> | 20 | </field> |
749 | 21 | </record> | 21 | </record> |
750 | 22 | 22 | ||
753 | 23 | <record id="sdd_mandate_partner_bank_tree" model="ir.ui.view"> | 23 | <record id="dd_mandate_partner_bank_tree" model="ir.ui.view"> |
754 | 24 | <field name="name">sdd.mandate.res.partner.bank.tree</field> | 24 | <field name="name">dd.mandate.res.partner.bank.tree</field> |
755 | 25 | <field name="model">res.partner.bank</field> | 25 | <field name="model">res.partner.bank</field> |
756 | 26 | <field name="inherit_id" ref="base.view_partner_bank_tree"/> | 26 | <field name="inherit_id" ref="base.view_partner_bank_tree"/> |
757 | 27 | <field name="arch" type="xml"> | 27 | <field name="arch" type="xml"> |
758 | 28 | <field name="partner_id" position="after"> | 28 | <field name="partner_id" position="after"> |
760 | 29 | <field name="sdd_mandate_ids" string="SDD Mandates"/> | 29 | <field name="mandate_ids" string="DD Mandates"/> |
761 | 30 | </field> | 30 | </field> |
762 | 31 | </field> | 31 | </field> |
763 | 32 | </record> | 32 | </record> |
764 | 33 | 33 | ||
769 | 34 | <!-- add number of mandates in this list of bank accounts | 34 | <!-- add number of mandates in this list of bank accounts on the partner form --> |
770 | 35 | on the partner form --> | 35 | <record id="dd_mandate_partner_form" model="ir.ui.view"> |
771 | 36 | <record id="sdd_mandate_partner_form" model="ir.ui.view"> | 36 | <field name="name">dd.mandate.partner.form</field> |
768 | 37 | <field name="name">sdd.mandate.partner.form</field> | ||
772 | 38 | <field name="model">res.partner</field> | 37 | <field name="model">res.partner</field> |
773 | 39 | <field name="inherit_id" ref="account.view_partner_property_form"/> | 38 | <field name="inherit_id" ref="account.view_partner_property_form"/> |
774 | 40 | <field name="arch" type="xml"> | 39 | <field name="arch" type="xml"> |
775 | 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"> |
777 | 42 | <field name="sdd_mandate_ids" string="SDD Mandates"/> | 41 | <field name="mandate_ids" string="DD Mandates"/> |
778 | 43 | </xpath> | 42 | </xpath> |
779 | 44 | </field> | 43 | </field> |
780 | 45 | </record> | 44 | </record> |
781 | 46 | 45 | ||
782 | === modified file 'account_banking_payment_export/model/payment_order_create.py' | |||
783 | --- account_banking_payment_export/model/payment_order_create.py 2014-03-22 00:53:03 +0000 | |||
784 | +++ account_banking_payment_export/model/payment_order_create.py 2014-07-29 07:49:30 +0000 | |||
785 | @@ -26,6 +26,10 @@ | |||
786 | 26 | from openerp.osv import orm, fields | 26 | from openerp.osv import orm, fields |
787 | 27 | from openerp.tools.translate import _ | 27 | from openerp.tools.translate import _ |
788 | 28 | 28 | ||
789 | 29 | import logging | ||
790 | 30 | |||
791 | 31 | logger = logging.getLogger(__name__) | ||
792 | 32 | |||
793 | 29 | 33 | ||
794 | 30 | class payment_order_create(orm.TransientModel): | 34 | class payment_order_create(orm.TransientModel): |
795 | 31 | _inherit = 'payment.order.create' | 35 | _inherit = 'payment.order.create' |
796 | @@ -48,6 +52,7 @@ | |||
797 | 48 | mod_obj = self.pool.get('ir.model.data') | 52 | mod_obj = self.pool.get('ir.model.data') |
798 | 49 | if context is None: | 53 | if context is None: |
799 | 50 | context = {} | 54 | context = {} |
800 | 55 | |||
801 | 51 | data = self.read(cr, uid, ids, ['duedate'], context=context)[0] | 56 | data = self.read(cr, uid, ids, ['duedate'], context=context)[0] |
802 | 52 | search_due_date = data['duedate'] | 57 | search_due_date = data['duedate'] |
803 | 53 | 58 | ||
804 | @@ -68,6 +73,7 @@ | |||
805 | 68 | '|', ('date_maturity', '<=', search_due_date), | 73 | '|', ('date_maturity', '<=', search_due_date), |
806 | 69 | ('date_maturity', '=', False) | 74 | ('date_maturity', '=', False) |
807 | 70 | ] | 75 | ] |
808 | 76 | |||
809 | 71 | line_ids = line_obj.search(cr, uid, domain, context=context) | 77 | line_ids = line_obj.search(cr, uid, domain, context=context) |
810 | 72 | context.update({'line_ids': line_ids}) | 78 | context.update({'line_ids': line_ids}) |
811 | 73 | model_data_ids = mod_obj.search( | 79 | model_data_ids = mod_obj.search( |
812 | 74 | 80 | ||
813 | === modified file 'account_banking_sepa_direct_debit/__openerp__.py' | |||
814 | --- account_banking_sepa_direct_debit/__openerp__.py 2014-03-12 22:18:33 +0000 | |||
815 | +++ account_banking_sepa_direct_debit/__openerp__.py 2014-07-29 07:49:30 +0000 | |||
816 | @@ -27,7 +27,7 @@ | |||
817 | 27 | 'author': 'Akretion', | 27 | 'author': 'Akretion', |
818 | 28 | 'website': 'http://www.akretion.com', | 28 | 'website': 'http://www.akretion.com', |
819 | 29 | 'category': 'Banking addons', | 29 | 'category': 'Banking addons', |
821 | 30 | 'depends': ['account_direct_debit', 'account_banking_pain_base'], | 30 | 'depends': ['account_banking_mandate', 'account_banking_pain_base', 'account_direct_debit'], |
822 | 31 | 'external_dependencies': { | 31 | 'external_dependencies': { |
823 | 32 | 'python': ['unidecode', 'lxml'], | 32 | 'python': ['unidecode', 'lxml'], |
824 | 33 | }, | 33 | }, |
825 | @@ -35,14 +35,11 @@ | |||
826 | 35 | 'security/original_mandate_required_security.xml', | 35 | 'security/original_mandate_required_security.xml', |
827 | 36 | 'account_banking_sdd_view.xml', | 36 | 'account_banking_sdd_view.xml', |
828 | 37 | 'sdd_mandate_view.xml', | 37 | 'sdd_mandate_view.xml', |
829 | 38 | 'res_partner_bank_view.xml', | ||
830 | 39 | 'account_payment_view.xml', | ||
831 | 40 | 'company_view.xml', | 38 | 'company_view.xml', |
832 | 41 | 'mandate_expire_cron.xml', | 39 | 'mandate_expire_cron.xml', |
833 | 42 | 'account_invoice_view.xml', | ||
834 | 43 | 'wizard/export_sdd_view.xml', | 40 | 'wizard/export_sdd_view.xml', |
835 | 44 | 'data/payment_type_sdd.xml', | 41 | 'data/payment_type_sdd.xml', |
837 | 45 | 'data/mandate_reference_sequence.xml', | 42 | 'data/sdd_mandate_sequence.xml', |
838 | 46 | 'security/ir.model.access.csv', | 43 | 'security/ir.model.access.csv', |
839 | 47 | ], | 44 | ], |
840 | 48 | 'demo': ['sepa_direct_debit_demo.xml'], | 45 | 'demo': ['sepa_direct_debit_demo.xml'], |
841 | 49 | 46 | ||
842 | === modified file 'account_banking_sepa_direct_debit/account_banking_sdd.py' | |||
843 | --- account_banking_sepa_direct_debit/account_banking_sdd.py 2014-06-23 09:47:01 +0000 | |||
844 | +++ account_banking_sepa_direct_debit/account_banking_sdd.py 2014-07-29 07:49:30 +0000 | |||
845 | @@ -32,7 +32,6 @@ | |||
846 | 32 | 32 | ||
847 | 33 | logger = logging.getLogger(__name__) | 33 | logger = logging.getLogger(__name__) |
848 | 34 | 34 | ||
849 | 35 | |||
850 | 36 | class banking_export_sdd(orm.Model): | 35 | class banking_export_sdd(orm.Model): |
851 | 37 | '''SEPA Direct Debit export''' | 36 | '''SEPA Direct Debit export''' |
852 | 38 | _name = 'banking.export.sdd' | 37 | _name = 'banking.export.sdd' |
853 | @@ -100,23 +99,10 @@ | |||
854 | 100 | 99 | ||
855 | 101 | class sdd_mandate(orm.Model): | 100 | class sdd_mandate(orm.Model): |
856 | 102 | '''SEPA Direct Debit Mandate''' | 101 | '''SEPA Direct Debit Mandate''' |
857 | 103 | _name = 'sdd.mandate' | ||
858 | 104 | _description = __doc__ | 102 | _description = __doc__ |
862 | 105 | _rec_name = 'unique_mandate_reference' | 103 | _name = 'account.banking.mandate' |
863 | 106 | _inherit = ['mail.thread'] | 104 | _inherit = 'account.banking.mandate' |
861 | 107 | _order = 'signature_date desc' | ||
864 | 108 | _track = { | 105 | _track = { |
865 | 109 | 'state': { | ||
866 | 110 | 'account_banking_sepa_direct_debit.mandate_valid': | ||
867 | 111 | lambda self, cr, uid, obj, ctx=None: | ||
868 | 112 | obj['state'] == 'valid', | ||
869 | 113 | 'account_banking_sepa_direct_debit.mandate_expired': | ||
870 | 114 | lambda self, cr, uid, obj, ctx=None: | ||
871 | 115 | obj['state'] == 'expired', | ||
872 | 116 | 'account_banking_sepa_direct_debit.mandate_cancel': | ||
873 | 117 | lambda self, cr, uid, obj, ctx=None: | ||
874 | 118 | obj['state'] == 'cancel', | ||
875 | 119 | }, | ||
876 | 120 | 'recurrent_sequence_type': { | 106 | 'recurrent_sequence_type': { |
877 | 121 | 'account_banking_sepa_direct_debit.recurrent_sequence_type_first': | 107 | 'account_banking_sepa_direct_debit.recurrent_sequence_type_first': |
878 | 122 | lambda self, cr, uid, obj, ctx=None: | 108 | lambda self, cr, uid, obj, ctx=None: |
879 | @@ -132,15 +118,6 @@ | |||
880 | 132 | } | 118 | } |
881 | 133 | 119 | ||
882 | 134 | _columns = { | 120 | _columns = { |
883 | 135 | 'partner_bank_id': fields.many2one( | ||
884 | 136 | 'res.partner.bank', 'Bank Account', track_visibility='onchange'), | ||
885 | 137 | 'partner_id': fields.related( | ||
886 | 138 | 'partner_bank_id', 'partner_id', type='many2one', | ||
887 | 139 | relation='res.partner', string='Partner', readonly=True), | ||
888 | 140 | 'company_id': fields.many2one('res.company', 'Company', required=True), | ||
889 | 141 | 'unique_mandate_reference': fields.char( | ||
890 | 142 | 'Unique Mandate Reference', size=35, readonly=True, | ||
891 | 143 | track_visibility='always'), | ||
892 | 144 | 'type': fields.selection([ | 121 | 'type': fields.selection([ |
893 | 145 | ('recurrent', 'Recurrent'), | 122 | ('recurrent', 'Recurrent'), |
894 | 146 | ('oneoff', 'One-Off'), | 123 | ('oneoff', 'One-Off'), |
895 | @@ -152,24 +129,6 @@ | |||
896 | 152 | ], 'Sequence Type for Next Debit', track_visibility='onchange', | 129 | ], 'Sequence Type for Next Debit', track_visibility='onchange', |
897 | 153 | help="This field is only used for Recurrent mandates, not for " | 130 | help="This field is only used for Recurrent mandates, not for " |
898 | 154 | "One-Off mandates."), | 131 | "One-Off mandates."), |
899 | 155 | 'signature_date': fields.date( | ||
900 | 156 | 'Date of Signature of the Mandate', track_visibility='onchange'), | ||
901 | 157 | 'scan': fields.binary('Scan of the Mandate'), | ||
902 | 158 | 'last_debit_date': fields.date( | ||
903 | 159 | 'Date of the Last Debit', readonly=True), | ||
904 | 160 | 'state': fields.selection([ | ||
905 | 161 | ('draft', 'Draft'), | ||
906 | 162 | ('valid', 'Valid'), | ||
907 | 163 | ('expired', 'Expired'), | ||
908 | 164 | ('cancel', 'Cancelled'), | ||
909 | 165 | ], 'Status', | ||
910 | 166 | help="Only valid mandates can be used in a payment line. A " | ||
911 | 167 | "cancelled mandate is a mandate that has been cancelled by " | ||
912 | 168 | "the customer. A one-off mandate expires after its first use. " | ||
913 | 169 | "A recurrent mandate expires after it's final use or if it " | ||
914 | 170 | "hasn't been used for 36 months."), | ||
915 | 171 | 'payment_line_ids': fields.one2many( | ||
916 | 172 | 'payment.line', 'sdd_mandate_id', "Related Payment Lines"), | ||
917 | 173 | 'sepa_migrated': fields.boolean( | 132 | 'sepa_migrated': fields.boolean( |
918 | 174 | 'Migrated to SEPA', track_visibility='onchange', | 133 | 'Migrated to SEPA', track_visibility='onchange', |
919 | 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 " |
920 | @@ -188,57 +147,11 @@ | |||
921 | 188 | } | 147 | } |
922 | 189 | 148 | ||
923 | 190 | _defaults = { | 149 | _defaults = { |
924 | 191 | 'company_id': lambda self, cr, uid, context: | ||
925 | 192 | self.pool['res.company']._company_default_get( | ||
926 | 193 | cr, uid, 'sdd.mandate', context=context), | ||
927 | 194 | 'unique_mandate_reference': '/', | ||
928 | 195 | 'state': 'draft', | ||
929 | 196 | 'sepa_migrated': True, | 150 | 'sepa_migrated': True, |
930 | 197 | } | 151 | } |
931 | 198 | 152 | ||
932 | 199 | _sql_constraints = [( | ||
933 | 200 | 'mandate_ref_company_uniq', | ||
934 | 201 | 'unique(unique_mandate_reference, company_id)', | ||
935 | 202 | 'A Mandate with the same reference already exists for this company !' | ||
936 | 203 | )] | ||
937 | 204 | |||
938 | 205 | def create(self, cr, uid, vals, context=None): | ||
939 | 206 | if vals.get('unique_mandate_reference', '/') == '/': | ||
940 | 207 | vals['unique_mandate_reference'] = \ | ||
941 | 208 | self.pool['ir.sequence'].next_by_code( | ||
942 | 209 | cr, uid, 'sdd.mandate.reference', context=context) | ||
943 | 210 | return super(sdd_mandate, self).create(cr, uid, vals, context=context) | ||
944 | 211 | |||
945 | 212 | def _check_sdd_mandate(self, cr, uid, ids): | 153 | def _check_sdd_mandate(self, cr, uid, ids): |
946 | 213 | for mandate in self.browse(cr, uid, ids): | 154 | for mandate in self.browse(cr, uid, ids): |
947 | 214 | if (mandate.signature_date and | ||
948 | 215 | mandate.signature_date > | ||
949 | 216 | datetime.today().strftime('%Y-%m-%d')): | ||
950 | 217 | raise orm.except_orm( | ||
951 | 218 | _('Error:'), | ||
952 | 219 | _("The date of signature of mandate '%s' is in the " | ||
953 | 220 | "future !") | ||
954 | 221 | % mandate.unique_mandate_reference) | ||
955 | 222 | if mandate.state == 'valid' and not mandate.signature_date: | ||
956 | 223 | raise orm.except_orm( | ||
957 | 224 | _('Error:'), | ||
958 | 225 | _("Cannot validate the mandate '%s' without a date of " | ||
959 | 226 | "signature.") | ||
960 | 227 | % mandate.unique_mandate_reference) | ||
961 | 228 | if mandate.state == 'valid' and not mandate.partner_bank_id: | ||
962 | 229 | raise orm.except_orm( | ||
963 | 230 | _('Error:'), | ||
964 | 231 | _("Cannot validate the mandate '%s' because it is not " | ||
965 | 232 | "attached to a bank account.") | ||
966 | 233 | % mandate.unique_mandate_reference) | ||
967 | 234 | |||
968 | 235 | if (mandate.signature_date and mandate.last_debit_date and | ||
969 | 236 | mandate.signature_date > mandate.last_debit_date): | ||
970 | 237 | raise orm.except_orm( | ||
971 | 238 | _('Error:'), | ||
972 | 239 | _("The mandate '%s' can't have a date of last debit " | ||
973 | 240 | "before the date of signature.") | ||
974 | 241 | % mandate.unique_mandate_reference) | ||
975 | 242 | if (mandate.type == 'recurrent' | 155 | if (mandate.type == 'recurrent' |
976 | 243 | and not mandate.recurrent_sequence_type): | 156 | and not mandate.recurrent_sequence_type): |
977 | 244 | raise orm.except_orm( | 157 | raise orm.except_orm( |
978 | @@ -265,11 +178,18 @@ | |||
979 | 265 | 178 | ||
980 | 266 | _constraints = [ | 179 | _constraints = [ |
981 | 267 | (_check_sdd_mandate, "Error msg in raise", [ | 180 | (_check_sdd_mandate, "Error msg in raise", [ |
982 | 268 | 'last_debit_date', 'signature_date', 'state', 'partner_bank_id', | ||
983 | 269 | 'type', 'recurrent_sequence_type', 'sepa_migrated', | 181 | 'type', 'recurrent_sequence_type', 'sepa_migrated', |
984 | 270 | 'original_mandate_identification', | 182 | 'original_mandate_identification', |
985 | 271 | ]), | 183 | ]), |
986 | 272 | ] | 184 | ] |
987 | 185 | |||
988 | 186 | def create(self, cr, uid, vals, context=None): | ||
989 | 187 | if vals.get('unique_mandate_reference', '/') == '/': | ||
990 | 188 | sequence = self.pool['ir.sequence'] | ||
991 | 189 | next_value = sequence.next_by_code(cr, uid, 'sdd.mandate.reference', context=context) | ||
992 | 190 | vals['unique_mandate_reference'] = next_value | ||
993 | 191 | |||
994 | 192 | return super(sdd_mandate, self).create(cr, uid, vals, context=context) | ||
995 | 273 | 193 | ||
996 | 274 | def mandate_type_change(self, cr, uid, ids, type): | 194 | def mandate_type_change(self, cr, uid, ids, type): |
997 | 275 | if type == 'recurrent': | 195 | if type == 'recurrent': |
998 | @@ -282,12 +202,8 @@ | |||
999 | 282 | def mandate_partner_bank_change( | 202 | def mandate_partner_bank_change( |
1000 | 283 | self, cr, uid, ids, partner_bank_id, type, recurrent_sequence_type, | 203 | self, cr, uid, ids, partner_bank_id, type, recurrent_sequence_type, |
1001 | 284 | last_debit_date, state): | 204 | last_debit_date, state): |
1008 | 285 | res = {'value': {}} | 205 | res = super(sdd_mandate, self).mandate_partner_bank_change(cr, uid, |
1009 | 286 | if partner_bank_id: | 206 | ids, partner_bank_id, last_debit_date, state) |
1004 | 287 | partner_bank_read = self.pool['res.partner.bank'].read( | ||
1005 | 288 | cr, uid, partner_bank_id, ['partner_id'])['partner_id'] | ||
1006 | 289 | if partner_bank_read: | ||
1007 | 290 | res['value']['partner_id'] = partner_bank_read[0] | ||
1010 | 291 | if (state == 'valid' and partner_bank_id | 207 | if (state == 'valid' and partner_bank_id |
1011 | 292 | and type == 'recurrent' | 208 | and type == 'recurrent' |
1012 | 293 | and recurrent_sequence_type != 'first'): | 209 | and recurrent_sequence_type != 'first'): |
1013 | @@ -301,35 +217,6 @@ | |||
1014 | 301 | } | 217 | } |
1015 | 302 | return res | 218 | return res |
1016 | 303 | 219 | ||
1017 | 304 | def validate(self, cr, uid, ids, context=None): | ||
1018 | 305 | to_validate_ids = [] | ||
1019 | 306 | for mandate in self.browse(cr, uid, ids, context=context): | ||
1020 | 307 | assert mandate.state == 'draft', 'Mandate should be in draft state' | ||
1021 | 308 | to_validate_ids.append(mandate.id) | ||
1022 | 309 | self.write( | ||
1023 | 310 | cr, uid, to_validate_ids, {'state': 'valid'}, context=context) | ||
1024 | 311 | return True | ||
1025 | 312 | |||
1026 | 313 | def cancel(self, cr, uid, ids, context=None): | ||
1027 | 314 | to_cancel_ids = [] | ||
1028 | 315 | for mandate in self.browse(cr, uid, ids, context=context): | ||
1029 | 316 | assert mandate.state in ('draft', 'valid'),\ | ||
1030 | 317 | 'Mandate should be in draft or valid state' | ||
1031 | 318 | to_cancel_ids.append(mandate.id) | ||
1032 | 319 | self.write( | ||
1033 | 320 | cr, uid, to_cancel_ids, {'state': 'cancel'}, context=context) | ||
1034 | 321 | return True | ||
1035 | 322 | |||
1036 | 323 | def back2draft(self, cr, uid, ids, context=None): | ||
1037 | 324 | to_draft_ids = [] | ||
1038 | 325 | for mandate in self.browse(cr, uid, ids, context=context): | ||
1039 | 326 | assert mandate.state == 'cancel',\ | ||
1040 | 327 | 'Mandate should be in cancel state' | ||
1041 | 328 | to_draft_ids.append(mandate.id) | ||
1042 | 329 | self.write( | ||
1043 | 330 | cr, uid, to_draft_ids, {'state': 'draft'}, context=context) | ||
1044 | 331 | return True | ||
1045 | 332 | |||
1046 | 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): |
1047 | 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') |
1048 | 335 | expire_limit_date = datetime.today() + \ | 222 | expire_limit_date = datetime.today() + \ |
1049 | @@ -351,90 +238,4 @@ | |||
1050 | 351 | % expired_mandate_ids) | 238 | % expired_mandate_ids) |
1051 | 352 | else: | 239 | else: |
1052 | 353 | logger.info('0 SDD Mandates must be set to Expired') | 240 | logger.info('0 SDD Mandates must be set to Expired') |
1140 | 354 | return True | 241 | return True |
1054 | 355 | |||
1055 | 356 | |||
1056 | 357 | class res_partner_bank(orm.Model): | ||
1057 | 358 | _inherit = 'res.partner.bank' | ||
1058 | 359 | |||
1059 | 360 | _columns = { | ||
1060 | 361 | 'sdd_mandate_ids': fields.one2many( | ||
1061 | 362 | 'sdd.mandate', 'partner_bank_id', 'SEPA Direct Debit Mandates'), | ||
1062 | 363 | } | ||
1063 | 364 | |||
1064 | 365 | |||
1065 | 366 | class payment_line(orm.Model): | ||
1066 | 367 | _inherit = 'payment.line' | ||
1067 | 368 | |||
1068 | 369 | _columns = { | ||
1069 | 370 | 'sdd_mandate_id': fields.many2one( | ||
1070 | 371 | 'sdd.mandate', 'SEPA Direct Debit Mandate', | ||
1071 | 372 | domain=[('state', '=', 'valid')]), | ||
1072 | 373 | } | ||
1073 | 374 | |||
1074 | 375 | def create(self, cr, uid, vals, context=None): | ||
1075 | 376 | '''If the customer invoice has a mandate, take it | ||
1076 | 377 | otherwise, take the first valid mandate of the bank account''' | ||
1077 | 378 | if context is None: | ||
1078 | 379 | context = {} | ||
1079 | 380 | if not vals: | ||
1080 | 381 | vals = {} | ||
1081 | 382 | partner_bank_id = vals.get('bank_id') | ||
1082 | 383 | move_line_id = vals.get('move_line_id') | ||
1083 | 384 | if (context.get('default_payment_order_type') == 'debit' | ||
1084 | 385 | and 'sdd_mandate_id' not in vals): | ||
1085 | 386 | if move_line_id: | ||
1086 | 387 | line = self.pool['account.move.line'].browse( | ||
1087 | 388 | cr, uid, move_line_id, context=context) | ||
1088 | 389 | if (line.invoice and line.invoice.type == 'out_invoice' | ||
1089 | 390 | and line.invoice.sdd_mandate_id): | ||
1090 | 391 | vals.update({ | ||
1091 | 392 | 'sdd_mandate_id': line.invoice.sdd_mandate_id.id, | ||
1092 | 393 | 'bank_id': | ||
1093 | 394 | line.invoice.sdd_mandate_id.partner_bank_id.id, | ||
1094 | 395 | }) | ||
1095 | 396 | if partner_bank_id and 'sdd_mandate_id' not in vals: | ||
1096 | 397 | mandate_ids = self.pool['sdd.mandate'].search(cr, uid, [ | ||
1097 | 398 | ('partner_bank_id', '=', partner_bank_id), | ||
1098 | 399 | ('state', '=', 'valid'), | ||
1099 | 400 | ], context=context) | ||
1100 | 401 | if mandate_ids: | ||
1101 | 402 | vals['sdd_mandate_id'] = mandate_ids[0] | ||
1102 | 403 | return super(payment_line, self).create(cr, uid, vals, context=context) | ||
1103 | 404 | |||
1104 | 405 | def _check_mandate_bank_link(self, cr, uid, ids): | ||
1105 | 406 | for payline in self.browse(cr, uid, ids): | ||
1106 | 407 | if (payline.sdd_mandate_id and payline.bank_id | ||
1107 | 408 | and payline.sdd_mandate_id.partner_bank_id.id != | ||
1108 | 409 | payline.bank_id.id): | ||
1109 | 410 | raise orm.except_orm( | ||
1110 | 411 | _('Error:'), | ||
1111 | 412 | _("The payment line with reference '%s' has the bank " | ||
1112 | 413 | "account '%s' which is not attached to the mandate " | ||
1113 | 414 | "'%s' (this mandate is attached to the bank account " | ||
1114 | 415 | "'%s').") % ( | ||
1115 | 416 | payline.name, | ||
1116 | 417 | self.pool['res.partner.bank'].name_get( | ||
1117 | 418 | cr, uid, [payline.bank_id.id])[0][1], | ||
1118 | 419 | payline.sdd_mandate_id.unique_mandate_reference, | ||
1119 | 420 | self.pool['res.partner.bank'].name_get( | ||
1120 | 421 | cr, uid, | ||
1121 | 422 | [payline.sdd_mandate_id.partner_bank_id.id])[0][1], | ||
1122 | 423 | )) | ||
1123 | 424 | return True | ||
1124 | 425 | |||
1125 | 426 | _constraints = [ | ||
1126 | 427 | (_check_mandate_bank_link, 'Error msg in raise', | ||
1127 | 428 | ['sdd_mandate_id', 'bank_id']), | ||
1128 | 429 | ] | ||
1129 | 430 | |||
1130 | 431 | |||
1131 | 432 | class account_invoice(orm.Model): | ||
1132 | 433 | _inherit = 'account.invoice' | ||
1133 | 434 | |||
1134 | 435 | _columns = { | ||
1135 | 436 | 'sdd_mandate_id': fields.many2one( | ||
1136 | 437 | 'sdd.mandate', 'SEPA Direct Debit Mandate', | ||
1137 | 438 | domain=[('state', '=', 'valid')], readonly=True, | ||
1138 | 439 | states={'draft': [('readonly', False)]}) | ||
1139 | 440 | } | ||
1141 | 441 | \ No newline at end of file | 242 | \ No newline at end of file |
1142 | 442 | 243 | ||
1143 | === added file 'account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml' | |||
1144 | --- account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml 1970-01-01 00:00:00 +0000 | |||
1145 | +++ account_banking_sepa_direct_debit/data/sdd_mandate_sequence.xml 2014-07-29 07:49:30 +0000 | |||
1146 | @@ -0,0 +1,17 @@ | |||
1147 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1148 | 2 | <openerp> | ||
1149 | 3 | <data noupdate="1"> | ||
1150 | 4 | <record id="sdd_mandate_seq_type" model="ir.sequence.type"> | ||
1151 | 5 | <field name="name">SDD Mandate Reference</field> | ||
1152 | 6 | <field name="code">sdd.mandate.reference</field> | ||
1153 | 7 | </record> | ||
1154 | 8 | |||
1155 | 9 | <record id="sdd_mandate_seq" model="ir.sequence"> | ||
1156 | 10 | <field name="name">SDD Mandate Reference</field> | ||
1157 | 11 | <field name="code">sdd.mandate.reference</field> | ||
1158 | 12 | <field name="prefix">RUM</field> | ||
1159 | 13 | <field name="padding" eval="7"/> | ||
1160 | 14 | <!-- remember that max size for the mandate ref is 35 --> | ||
1161 | 15 | </record> | ||
1162 | 16 | </data> | ||
1163 | 17 | </openerp> | ||
1164 | 0 | 18 | ||
1165 | === modified file 'account_banking_sepa_direct_debit/mandate_expire_cron.xml' | |||
1166 | --- account_banking_sepa_direct_debit/mandate_expire_cron.xml 2013-11-07 22:22:19 +0000 | |||
1167 | +++ account_banking_sepa_direct_debit/mandate_expire_cron.xml 2014-07-29 07:49:30 +0000 | |||
1168 | @@ -17,7 +17,7 @@ | |||
1169 | 17 | <field name="interval_type">days</field> | 17 | <field name="interval_type">days</field> |
1170 | 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 --> |
1171 | 19 | <field name="doall" eval="False"/> | 19 | <field name="doall" eval="False"/> |
1173 | 20 | <field name="model" eval="'sdd.mandate'"/> | 20 | <field name="model" eval="'account.banking.mandate'"/> |
1174 | 21 | <field name="function" eval="'_sdd_mandate_set_state_to_expired'" /> | 21 | <field name="function" eval="'_sdd_mandate_set_state_to_expired'" /> |
1175 | 22 | <field name="args" eval="'()'"/> | 22 | <field name="args" eval="'()'"/> |
1176 | 23 | </record> | 23 | </record> |
1177 | 24 | 24 | ||
1178 | === added file 'account_banking_sepa_direct_debit/sdd_mandate_view.xml' | |||
1179 | --- account_banking_sepa_direct_debit/sdd_mandate_view.xml 1970-01-01 00:00:00 +0000 | |||
1180 | +++ account_banking_sepa_direct_debit/sdd_mandate_view.xml 2014-07-29 07:49:30 +0000 | |||
1181 | @@ -0,0 +1,133 @@ | |||
1182 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
1183 | 2 | <!-- | ||
1184 | 3 | Copyright (C) 2013 Akretion (http://www.akretion.com) | ||
1185 | 4 | @author: Alexis de Lattre <alexis.delattre@akretion.com> | ||
1186 | 5 | The licence is in the file __openerp__.py | ||
1187 | 6 | --> | ||
1188 | 7 | <!-- | ||
1189 | 8 | Customize all mandate views (and actions) to fit SEPA mandate style | ||
1190 | 9 | --> | ||
1191 | 10 | <openerp> | ||
1192 | 11 | <data> | ||
1193 | 12 | <record id="sdd_mandate_form" model="ir.ui.view"> | ||
1194 | 13 | <field name="name">sdd.mandate.form</field> | ||
1195 | 14 | <field name="model">account.banking.mandate</field> | ||
1196 | 15 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_form"/> | ||
1197 | 16 | <field name="arch" type="xml"> | ||
1198 | 17 | <data> | ||
1199 | 18 | <xpath expr="//field[@name='partner_id']" position="after"> | ||
1200 | 19 | <field name="type" on_change="mandate_type_change(type)"/> | ||
1201 | 20 | <field name="recurrent_sequence_type" attrs="{'invisible': [('type', '=', 'oneoff')], 'required': [('type', '=', 'recurrent')]}"/> | ||
1202 | 21 | </xpath> | ||
1203 | 22 | <xpath expr="//field[@name='partner_bank_id']" position="attributes"> | ||
1204 | 23 | <attribute name="on_change">mandate_partner_bank_change(partner_bank_id, type, recurrent_sequence_type, last_debit_date, state)</attribute> | ||
1205 | 24 | </xpath> | ||
1206 | 25 | <xpath expr="//field[@name='last_debit_date']" position="after"> | ||
1207 | 26 | <field name="sepa_migrated" groups="account_banking_sepa_direct_debit.group_original_mandate_required"/> | ||
1208 | 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"/> | ||
1209 | 28 | </xpath> | ||
1210 | 29 | </data> | ||
1211 | 30 | </field> | ||
1212 | 31 | </record> | ||
1213 | 32 | |||
1214 | 33 | <record id="sdd_mandate_tree" model="ir.ui.view"> | ||
1215 | 34 | <field name="name">sdd.mandate.tree</field> | ||
1216 | 35 | <field name="model">account.banking.mandate</field> | ||
1217 | 36 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_tree"/> | ||
1218 | 37 | <field name="arch" type="xml"> | ||
1219 | 38 | <data> | ||
1220 | 39 | <xpath expr="//field[@name='unique_mandate_reference']" position="after"> | ||
1221 | 40 | <field name="type" string="Type"/> | ||
1222 | 41 | </xpath> | ||
1223 | 42 | </data> | ||
1224 | 43 | </field> | ||
1225 | 44 | </record> | ||
1226 | 45 | |||
1227 | 46 | <record id="sdd_mandate_search" model="ir.ui.view"> | ||
1228 | 47 | <field name="name">sdd.mandate.search</field> | ||
1229 | 48 | <field name="model">account.banking.mandate</field> | ||
1230 | 49 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_search"/> | ||
1231 | 50 | <field name="arch" type="xml"> | ||
1232 | 51 | <xpath expr="//filter[@name='expired']" position="after"> | ||
1233 | 52 | <filter name="oneoff" string="One-Off" domain="[('type', '=', 'oneoff')]" /> | ||
1234 | 53 | <filter name="recurrent" string="Recurrent" domain="[('type', '=', 'recurrent')]" /> | ||
1235 | 54 | </xpath> | ||
1236 | 55 | </field> | ||
1237 | 56 | </record> | ||
1238 | 57 | |||
1239 | 58 | <record id="dd_mandate_action" model="ir.actions.act_window"> | ||
1240 | 59 | <field name="name">SEPA Direct Debit Mandates</field> | ||
1241 | 60 | <field name="res_model">account.banking.mandate</field> | ||
1242 | 61 | <field name="view_type">form</field> | ||
1243 | 62 | <field name="view_mode">tree,form</field> | ||
1244 | 63 | <field name="help" type="html"> | ||
1245 | 64 | <p class="oe_view_nocontent_create"> | ||
1246 | 65 | Click to create a new SEPA Direct Debit Mandate. | ||
1247 | 66 | </p><p> | ||
1248 | 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. | ||
1249 | 68 | </p> | ||
1250 | 69 | </field> | ||
1251 | 70 | </record> | ||
1252 | 71 | |||
1253 | 72 | <menuitem id="account_banking_mandate.dd_mandate_menu" | ||
1254 | 73 | parent="account_payment.menu_main_payment" | ||
1255 | 74 | action="dd_mandate_action" | ||
1256 | 75 | sequence="40" | ||
1257 | 76 | /> | ||
1258 | 77 | |||
1259 | 78 | <record id="sdd_mandate_partner_bank_form" model="ir.ui.view"> | ||
1260 | 79 | <field name="name">sdd.mandate.res.partner.bank.form</field> | ||
1261 | 80 | <field name="model">res.partner.bank</field> | ||
1262 | 81 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_form"/> | ||
1263 | 82 | <field name="arch" type="xml"> | ||
1264 | 83 | <xpath expr="//group[@name='dd_mandates']" position="attributes"> | ||
1265 | 84 | <attribute name="string">SEPA Direct Debit Mandates</attribute> | ||
1266 | 85 | </xpath> | ||
1267 | 86 | </field> | ||
1268 | 87 | </record> | ||
1269 | 88 | |||
1270 | 89 | <record id="sdd_mandate_partner_bank_tree" model="ir.ui.view"> | ||
1271 | 90 | <field name="name">sdd.mandate.res.partner.bank.tree</field> | ||
1272 | 91 | <field name="model">res.partner.bank</field> | ||
1273 | 92 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_bank_tree"/> | ||
1274 | 93 | <field name="arch" type="xml"> | ||
1275 | 94 | <xpath expr="//field[@name='mandate_ids']" position="attributes"> | ||
1276 | 95 | <attribute name="string">SDD Mandates</attribute> | ||
1277 | 96 | </xpath> | ||
1278 | 97 | </field> | ||
1279 | 98 | </record> | ||
1280 | 99 | |||
1281 | 100 | <record id="sdd_mandate_partner_form" model="ir.ui.view"> | ||
1282 | 101 | <field name="name">sdd.mandate.partner.form</field> | ||
1283 | 102 | <field name="model">res.partner</field> | ||
1284 | 103 | <field name="inherit_id" ref="account_banking_mandate.dd_mandate_partner_form"/> | ||
1285 | 104 | <field name="arch" type="xml"> | ||
1286 | 105 | <xpath expr="//field[@name='bank_ids']/tree/field[@name='mandate_ids']" position="attributes"> | ||
1287 | 106 | <attribute name="string">SDD Mandates</attribute> | ||
1288 | 107 | </xpath> | ||
1289 | 108 | </field> | ||
1290 | 109 | </record> | ||
1291 | 110 | |||
1292 | 111 | <!-- notifications in the chatter --> | ||
1293 | 112 | <record id="recurrent_sequence_type_first" model="mail.message.subtype"> | ||
1294 | 113 | <field name="name">Sequence Type set to First</field> | ||
1295 | 114 | <field name="res_model">account.banking.mandate</field> | ||
1296 | 115 | <field name="default" eval="False"/> | ||
1297 | 116 | <field name="description">Sequence Type set to First</field> | ||
1298 | 117 | </record> | ||
1299 | 118 | |||
1300 | 119 | <record id="recurrent_sequence_type_recurring" model="mail.message.subtype"> | ||
1301 | 120 | <field name="name">Sequence Type set to Recurring</field> | ||
1302 | 121 | <field name="res_model">account.banking.mandate</field> | ||
1303 | 122 | <field name="default" eval="False"/> | ||
1304 | 123 | <field name="description">Sequence Type set to Recurring</field> | ||
1305 | 124 | </record> | ||
1306 | 125 | |||
1307 | 126 | <record id="recurrent_sequence_type_final" model="mail.message.subtype"> | ||
1308 | 127 | <field name="name">Sequence Type set to Final</field> | ||
1309 | 128 | <field name="res_model">account.banking.mandate</field> | ||
1310 | 129 | <field name="default" eval="False"/> | ||
1311 | 130 | <field name="description">Sequence Type set to Final</field> | ||
1312 | 131 | </record> | ||
1313 | 132 | </data> | ||
1314 | 133 | </openerp> | ||
1315 | 0 | 134 | ||
1316 | === modified file 'account_banking_sepa_direct_debit/security/ir.model.access.csv' | |||
1317 | --- account_banking_sepa_direct_debit/security/ir.model.access.csv 2013-10-15 21:29:28 +0000 | |||
1318 | +++ account_banking_sepa_direct_debit/security/ir.model.access.csv 2014-07-29 07:49:30 +0000 | |||
1319 | @@ -1,4 +1,4 @@ | |||
1320 | 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" |
1321 | 2 | "access_banking_export_sdd","Full access on banking.export.sdd","model_banking_export_sdd","account_payment.group_account_payment",1,1,1,1 | 2 | "access_banking_export_sdd","Full access on banking.export.sdd","model_banking_export_sdd","account_payment.group_account_payment",1,1,1,1 |
1324 | 3 | "access_sdd_mandate","Full access on sdd.mandate","model_sdd_mandate","account_payment.group_account_payment",1,1,1,1 | 3 | "access_sdd_mandate","Full access on sdd.mandate","model_account_banking_mandate","account_payment.group_account_payment",1,1,1,1 |
1325 | 4 | "access_sdd_mandate_read","Read access on sdd.mandate","model_sdd_mandate","base.group_user",1,0,0,0 | 4 | "access_sdd_mandate_read","Read access on sdd.mandate","model_account_banking_mandate","base.group_user",1,0,0,0 |
1326 | 5 | 5 | ||
1327 | === modified file 'account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml' | |||
1328 | --- account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-02-16 14:01:09 +0000 | |||
1329 | +++ account_banking_sepa_direct_debit/sepa_direct_debit_demo.xml 2014-07-29 07:49:30 +0000 | |||
1330 | @@ -15,7 +15,7 @@ | |||
1331 | 15 | <field name="sepa_creditor_identifier">FR78ZZZ424242</field> | 15 | <field name="sepa_creditor_identifier">FR78ZZZ424242</field> |
1332 | 16 | </record> | 16 | </record> |
1333 | 17 | 17 | ||
1335 | 18 | <record id="res_partner_12_mandate" model="sdd.mandate"> | 18 | <record id="res_partner_12_mandate" model="account.banking.mandate"> |
1336 | 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"/> |
1337 | 20 | <field name="type">recurrent</field> | 20 | <field name="type">recurrent</field> |
1338 | 21 | <field name="recurrent_sequence_type">first</field> | 21 | <field name="recurrent_sequence_type">first</field> |
1339 | 22 | 22 | ||
1340 | === modified file 'account_banking_sepa_direct_debit/wizard/export_sdd.py' | |||
1341 | --- account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-01-05 23:51:22 +0000 | |||
1342 | +++ account_banking_sepa_direct_debit/wizard/export_sdd.py 2014-07-29 07:49:30 +0000 | |||
1343 | @@ -93,7 +93,7 @@ | |||
1344 | 93 | previous_bank = False | 93 | previous_bank = False |
1345 | 94 | payline_ids = payline_obj.search( | 94 | payline_ids = payline_obj.search( |
1346 | 95 | cr, uid, [ | 95 | cr, uid, [ |
1348 | 96 | ('sdd_mandate_id', '=', payline.sdd_mandate_id.id), | 96 | ('mandate_id', '=', payline.mandate_id.id), |
1349 | 97 | ('bank_id', '!=', payline.bank_id.id), | 97 | ('bank_id', '!=', payline.bank_id.id), |
1350 | 98 | ], | 98 | ], |
1351 | 99 | context=context) | 99 | context=context) |
1352 | @@ -188,22 +188,22 @@ | |||
1353 | 188 | requested_date = payment_order.date_scheduled or today | 188 | requested_date = payment_order.date_scheduled or today |
1354 | 189 | else: | 189 | else: |
1355 | 190 | requested_date = today | 190 | requested_date = today |
1357 | 191 | if not line.sdd_mandate_id: | 191 | if not line.mandate_id: |
1358 | 192 | raise orm.except_orm( | 192 | raise orm.except_orm( |
1359 | 193 | _('Error:'), | 193 | _('Error:'), |
1360 | 194 | _("Missing SEPA Direct Debit mandate on the payment " | 194 | _("Missing SEPA Direct Debit mandate on the payment " |
1361 | 195 | "line with partner '%s' and Invoice ref '%s'.") | 195 | "line with partner '%s' and Invoice ref '%s'.") |
1362 | 196 | % (line.partner_id.name, | 196 | % (line.partner_id.name, |
1363 | 197 | line.ml_inv_ref.number)) | 197 | line.ml_inv_ref.number)) |
1365 | 198 | if line.sdd_mandate_id.state != 'valid': | 198 | if line.mandate_id.state != 'valid': |
1366 | 199 | raise orm.except_orm( | 199 | raise orm.except_orm( |
1367 | 200 | _('Error:'), | 200 | _('Error:'), |
1368 | 201 | _("The SEPA Direct Debit mandate with reference '%s' " | 201 | _("The SEPA Direct Debit mandate with reference '%s' " |
1369 | 202 | "for partner '%s' has expired.") | 202 | "for partner '%s' has expired.") |
1374 | 203 | % (line.sdd_mandate_id.unique_mandate_reference, | 203 | % (line.mandate_id.unique_mandate_reference, |
1375 | 204 | line.sdd_mandate_id.partner_id.name)) | 204 | line.mandate_id.partner_id.name)) |
1376 | 205 | if line.sdd_mandate_id.type == 'oneoff': | 205 | if line.mandate_id.type == 'oneoff': |
1377 | 206 | if not line.sdd_mandate_id.last_debit_date: | 206 | if not line.mandate_id.last_debit_date: |
1378 | 207 | seq_type = 'OOFF' | 207 | seq_type = 'OOFF' |
1379 | 208 | else: | 208 | else: |
1380 | 209 | raise orm.except_orm( | 209 | raise orm.except_orm( |
1381 | @@ -212,17 +212,17 @@ | |||
1382 | 212 | "'%s' has type set to 'One-Off' and it has a " | 212 | "'%s' has type set to 'One-Off' and it has a " |
1383 | 213 | "last debit date set to '%s', so we can't use " | 213 | "last debit date set to '%s', so we can't use " |
1384 | 214 | "it.") | 214 | "it.") |
1389 | 215 | % (line.sdd_mandate_id.unique_mandate_reference, | 215 | % (line.mandate_id.unique_mandate_reference, |
1390 | 216 | line.sdd_mandate_id.partner_id.name, | 216 | line.mandate_id.partner_id.name, |
1391 | 217 | line.sdd_mandate_id.last_debit_date)) | 217 | line.mandate_id.last_debit_date)) |
1392 | 218 | elif line.sdd_mandate_id.type == 'recurrent': | 218 | elif line.mandate_id.type == 'recurrent': |
1393 | 219 | seq_type_map = { | 219 | seq_type_map = { |
1394 | 220 | 'recurring': 'RCUR', | 220 | 'recurring': 'RCUR', |
1395 | 221 | 'first': 'FRST', | 221 | 'first': 'FRST', |
1396 | 222 | 'final': 'FNAL', | 222 | 'final': 'FNAL', |
1397 | 223 | } | 223 | } |
1398 | 224 | seq_type_label = \ | 224 | seq_type_label = \ |
1400 | 225 | line.sdd_mandate_id.recurrent_sequence_type | 225 | line.mandate_id.recurrent_sequence_type |
1401 | 226 | assert seq_type_label is not False | 226 | assert seq_type_label is not False |
1402 | 227 | seq_type = seq_type_map[seq_type_label] | 227 | seq_type = seq_type_map[seq_type_label] |
1403 | 228 | 228 | ||
1404 | @@ -306,22 +306,22 @@ | |||
1405 | 306 | mandate_related_info_2_47, 'MndtId') | 306 | mandate_related_info_2_47, 'MndtId') |
1406 | 307 | mandate_identification_2_48.text = self._prepare_field( | 307 | mandate_identification_2_48.text = self._prepare_field( |
1407 | 308 | cr, uid, 'Unique Mandate Reference', | 308 | cr, uid, 'Unique Mandate Reference', |
1409 | 309 | 'line.sdd_mandate_id.unique_mandate_reference', | 309 | 'line.mandate_id.unique_mandate_reference', |
1410 | 310 | {'line': line}, 35, | 310 | {'line': line}, 35, |
1411 | 311 | gen_args=gen_args, context=context) | 311 | gen_args=gen_args, context=context) |
1412 | 312 | mandate_signature_date_2_49 = etree.SubElement( | 312 | mandate_signature_date_2_49 = etree.SubElement( |
1413 | 313 | mandate_related_info_2_47, 'DtOfSgntr') | 313 | mandate_related_info_2_47, 'DtOfSgntr') |
1414 | 314 | mandate_signature_date_2_49.text = self._prepare_field( | 314 | mandate_signature_date_2_49.text = self._prepare_field( |
1415 | 315 | cr, uid, 'Mandate Signature Date', | 315 | cr, uid, 'Mandate Signature Date', |
1417 | 316 | 'line.sdd_mandate_id.signature_date', | 316 | 'line.mandate_id.signature_date', |
1418 | 317 | {'line': line}, 10, | 317 | {'line': line}, 10, |
1419 | 318 | gen_args=gen_args, context=context) | 318 | gen_args=gen_args, context=context) |
1420 | 319 | if sequence_type == 'FRST' and ( | 319 | if sequence_type == 'FRST' and ( |
1423 | 320 | line.sdd_mandate_id.last_debit_date or | 320 | line.mandate_id.last_debit_date or |
1424 | 321 | not line.sdd_mandate_id.sepa_migrated): | 321 | not line.mandate_id.sepa_migrated): |
1425 | 322 | previous_bank = self._get_previous_bank( | 322 | previous_bank = self._get_previous_bank( |
1426 | 323 | cr, uid, line, context=context) | 323 | cr, uid, line, context=context) |
1428 | 324 | if previous_bank or not line.sdd_mandate_id.sepa_migrated: | 324 | if previous_bank or not line.mandate_id.sepa_migrated: |
1429 | 325 | amendment_indicator_2_50 = etree.SubElement( | 325 | amendment_indicator_2_50 = etree.SubElement( |
1430 | 326 | mandate_related_info_2_47, 'AmdmntInd') | 326 | mandate_related_info_2_47, 'AmdmntInd') |
1431 | 327 | amendment_indicator_2_50.text = 'true' | 327 | amendment_indicator_2_50.text = 'true' |
1432 | @@ -362,13 +362,13 @@ | |||
1433 | 362 | ori_debtor_agent_other, 'Id') | 362 | ori_debtor_agent_other, 'Id') |
1434 | 363 | ori_debtor_agent_other_id.text = 'SMNDA' | 363 | ori_debtor_agent_other_id.text = 'SMNDA' |
1435 | 364 | # SMNDA = Same Mandate New Debtor Agent | 364 | # SMNDA = Same Mandate New Debtor Agent |
1437 | 365 | elif not line.sdd_mandate_id.sepa_migrated: | 365 | elif not line.mandate_id.sepa_migrated: |
1438 | 366 | ori_mandate_identification_2_52 = etree.SubElement( | 366 | ori_mandate_identification_2_52 = etree.SubElement( |
1439 | 367 | amendment_info_details_2_51, 'OrgnlMndtId') | 367 | amendment_info_details_2_51, 'OrgnlMndtId') |
1440 | 368 | ori_mandate_identification_2_52.text = \ | 368 | ori_mandate_identification_2_52.text = \ |
1441 | 369 | self._prepare_field( | 369 | self._prepare_field( |
1442 | 370 | cr, uid, 'Original Mandate Identification', | 370 | cr, uid, 'Original Mandate Identification', |
1444 | 371 | 'line.sdd_mandate_id.' | 371 | 'line.mandate_id.' |
1445 | 372 | 'original_mandate_identification', | 372 | 'original_mandate_identification', |
1446 | 373 | {'line': line}, | 373 | {'line': line}, |
1447 | 374 | gen_args=gen_args, | 374 | gen_args=gen_args, |
1448 | @@ -425,25 +425,25 @@ | |||
1449 | 425 | wf_service = netsvc.LocalService('workflow') | 425 | wf_service = netsvc.LocalService('workflow') |
1450 | 426 | for order in sepa_export.payment_order_ids: | 426 | for order in sepa_export.payment_order_ids: |
1451 | 427 | wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr) | 427 | wf_service.trg_validate(uid, 'payment.order', order.id, 'done', cr) |
1454 | 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] |
1455 | 429 | self.pool['sdd.mandate'].write( | 429 | self.pool['account.banking.mandate'].write( |
1456 | 430 | cr, uid, mandate_ids, | 430 | cr, uid, mandate_ids, |
1457 | 431 | {'last_debit_date': datetime.today().strftime('%Y-%m-%d')}, | 431 | {'last_debit_date': datetime.today().strftime('%Y-%m-%d')}, |
1458 | 432 | context=context) | 432 | context=context) |
1459 | 433 | to_expire_ids = [] | 433 | to_expire_ids = [] |
1460 | 434 | first_mandate_ids = [] | 434 | first_mandate_ids = [] |
1461 | 435 | for line in order.line_ids: | 435 | for line in order.line_ids: |
1466 | 436 | if line.sdd_mandate_id.type == 'oneoff': | 436 | if line.mandate_id.type == 'oneoff': |
1467 | 437 | to_expire_ids.append(line.sdd_mandate_id.id) | 437 | to_expire_ids.append(line.mandate_id.id) |
1468 | 438 | elif line.sdd_mandate_id.type == 'recurrent': | 438 | elif line.mandate_id.type == 'recurrent': |
1469 | 439 | seq_type = line.sdd_mandate_id.recurrent_sequence_type | 439 | seq_type = line.mandate_id.recurrent_sequence_type |
1470 | 440 | if seq_type == 'final': | 440 | if seq_type == 'final': |
1472 | 441 | to_expire_ids.append(line.sdd_mandate_id.id) | 441 | to_expire_ids.append(line.mandate_id.id) |
1473 | 442 | elif seq_type == 'first': | 442 | elif seq_type == 'first': |
1476 | 443 | first_mandate_ids.append(line.sdd_mandate_id.id) | 443 | first_mandate_ids.append(line.mandate_id.id) |
1477 | 444 | self.pool['sdd.mandate'].write( | 444 | self.pool['account.banking.mandate'].write( |
1478 | 445 | cr, uid, to_expire_ids, {'state': 'expired'}, context=context) | 445 | cr, uid, to_expire_ids, {'state': 'expired'}, context=context) |
1480 | 446 | self.pool['sdd.mandate'].write( | 446 | self.pool['account.banking.mandate'].write( |
1481 | 447 | cr, uid, first_mandate_ids, { | 447 | cr, uid, first_mandate_ids, { |
1482 | 448 | 'recurrent_sequence_type': 'recurring', | 448 | 'recurrent_sequence_type': 'recurring', |
1483 | 449 | 'sepa_migrated': True, | 449 | 'sepa_migrated': True, |
Temporary MP to help review