Merge lp:~avanzosc/sepa-tools/7.0 into lp:sepa-tools

Proposed by Oihane (Avanzosc)
Status: Merged
Merged at revision: 8
Proposed branch: lp:~avanzosc/sepa-tools/7.0
Merge into: lp:sepa-tools
Diff against target: 468 lines (+423/-0)
8 files modified
l10n_es_iban_converter/__init__.py (+24/-0)
l10n_es_iban_converter/__openerp__.py (+46/-0)
l10n_es_iban_converter/i18n/es.po (+83/-0)
l10n_es_iban_converter/i18n/l10n_es_iban_converter.pot (+83/-0)
l10n_es_iban_converter/views/res_partner_view_ext.xml (+10/-0)
l10n_es_iban_converter/wizard/__init__.py (+24/-0)
l10n_es_iban_converter/wizard/wizard_partner_cc_iban.py (+122/-0)
l10n_es_iban_converter/wizard/wizard_partner_cc_iban_view.xml (+31/-0)
To merge this branch: bzr merge lp:~avanzosc/sepa-tools/7.0
Reviewer Review Type Date Requested Status
Pedro Manuel Baeza code review Approve
Ignacio Ibeas (www.acysos.com) Pending
Review via email: mp+229446@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Some comments inline.

Regards.

review: Needs Fixing (code review)
Revision history for this message
Oihane (Avanzosc) (oihanecruce) wrote :

Sorry I forgot to pass again Flake8 to validate if all the code was pep8 complaining

lp:~avanzosc/sepa-tools/7.0 updated
9. By Oihane (Avanzosc)

[MOD] Modifications requested on MP

Revision history for this message
Oihane (Avanzosc) (oihanecruce) wrote :

Ready for other review

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM

review: Approve (code review)
lp:~avanzosc/sepa-tools/7.0 updated
10. By Oihane (Avanzosc)

[FIX] Little mistake solved, worked wrongly

11. By Oihane (Avanzosc)

[MOD] Description adapted

12. By Oihane (Avanzosc)

[MOD] Format acc_number

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'l10n_es_iban_converter'
2=== added file 'l10n_es_iban_converter/__init__.py'
3--- l10n_es_iban_converter/__init__.py 1970-01-01 00:00:00 +0000
4+++ l10n_es_iban_converter/__init__.py 2014-08-05 10:25:46 +0000
5@@ -0,0 +1,24 @@
6+# -*- encoding: utf-8 -*-
7+########################################################################
8+#
9+# @authors: Ignacio Ibeas <ignacio@acysos.com>
10+# Copyright (C) 2013 Acysos S.L.
11+#
12+#This program is free software: you can redistribute it and/or modify
13+#it under the terms of the GNU General Public License as published by
14+#the Free Software Foundation, either version 3 of the License, or
15+#(at your option) any later version.
16+#
17+# This module is GPLv3 or newer and incompatible
18+# with OpenERP SA "AGPL + Private Use License"!
19+#
20+#This program is distributed in the hope that it will be useful,
21+#but WITHOUT ANY WARRANTY; without even the implied warranty of
22+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+#GNU General Public License for more details.
24+#
25+#You should have received a copy of the GNU General Public License
26+#along with this program. If not, see http://www.gnu.org/licenses.
27+########################################################################
28+
29+from . import wizard
30
31=== added file 'l10n_es_iban_converter/__openerp__.py'
32--- l10n_es_iban_converter/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ l10n_es_iban_converter/__openerp__.py 2014-08-05 10:25:46 +0000
34@@ -0,0 +1,46 @@
35+# -*- encoding: utf-8 -*-
36+########################################################################
37+#
38+# @authors: Ignacio Ibeas <ignacio@acysos.com>
39+# Copyright (C) 2013 Acysos S.L.
40+#
41+#This program is free software: you can redistribute it and/or modify
42+#it under the terms of the GNU General Public License as published by
43+#the Free Software Foundation, either version 3 of the License, or
44+#(at your option) any later version.
45+#
46+# This module is GPLv3 or newer and incompatible
47+# with OpenERP SA "AGPL + Private Use License"!
48+#
49+#This program is distributed in the hope that it will be useful,
50+#but WITHOUT ANY WARRANTY; without even the implied warranty of
51+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52+#GNU General Public License for more details.
53+#
54+#You should have received a copy of the GNU General Public License
55+#along with this program. If not, see http://www.gnu.org/licenses.
56+########################################################################
57+
58+{
59+ "name": "IBAN Converter - Spanish localization",
60+ "version": "1.0",
61+ "depends": [
62+ "base",
63+ "base_iban",
64+ "l10n_es_partner",
65+ ],
66+ "author": "Acysos S.L., Avanzosc S.L.",
67+ "website": "http://www.acysos.com, http://www.avanzosc.com",
68+ "category": "Tools",
69+ "complexity": "normal",
70+ "description": """
71+This module create one action in res.partner object to convert CCC to IBAN
72+and vice versa.
73+ """,
74+ "data": [
75+ 'wizard/wizard_partner_cc_iban_view.xml',
76+ 'views/res_partner_view_ext.xml',
77+ ],
78+ 'installable': True,
79+ 'auto_install': False,
80+}
81
82=== added directory 'l10n_es_iban_converter/i18n'
83=== added file 'l10n_es_iban_converter/i18n/es.po'
84--- l10n_es_iban_converter/i18n/es.po 1970-01-01 00:00:00 +0000
85+++ l10n_es_iban_converter/i18n/es.po 2014-08-05 10:25:46 +0000
86@@ -0,0 +1,83 @@
87+# Translation of Odoo Server.
88+# This file contains the translation of the following modules:
89+# * l10n_es_iban_converter
90+#
91+msgid ""
92+msgstr ""
93+"Project-Id-Version: Odoo Server 8.0rc1\n"
94+"Report-Msgid-Bugs-To: \n"
95+"POT-Creation-Date: 2014-08-04 14:03+0000\n"
96+"PO-Revision-Date: 2014-08-04 14:03+0000\n"
97+"Last-Translator: <>\n"
98+"Language-Team: \n"
99+"MIME-Version: 1.0\n"
100+"Content-Type: text/plain; charset=UTF-8\n"
101+"Content-Transfer-Encoding: \n"
102+"Plural-Forms: \n"
103+
104+#. module: l10n_es_iban_converter
105+#: field:wizard.partner.cc.iban,bank_state:0
106+msgid "Bank Account Type"
107+msgstr "Tipo de cuenta de banco"
108+
109+#. module: l10n_es_iban_converter
110+#: model:ir.model,name:l10n_es_iban_converter.model_res_partner_bank
111+msgid "Bank Accounts"
112+msgstr "Cuentas de banco"
113+
114+#. module: l10n_es_iban_converter
115+#: view:wizard.partner.cc.iban:0
116+msgid "Cancel"
117+msgstr "Cancelar"
118+
119+#. module: l10n_es_iban_converter
120+#: view:wizard.partner.cc.iban:0
121+msgid "Convert"
122+msgstr "Convertir"
123+
124+#. module: l10n_es_iban_converter
125+#: model:ir.actions.act_window,name:l10n_es_iban_converter.action_partner_to_cciban
126+#: view:wizard.partner.cc.iban:0
127+msgid "Convert CCC <-> IBAN"
128+msgstr "Convertir CCC <-> IBAN"
129+
130+#. module: l10n_es_iban_converter
131+#: field:wizard.partner.cc.iban,create_uid:0
132+msgid "Created by"
133+msgstr "Creado por"
134+
135+#. module: l10n_es_iban_converter
136+#: field:wizard.partner.cc.iban,create_date:0
137+msgid "Created on"
138+msgstr "Creado el"
139+
140+#. module: l10n_es_iban_converter
141+#: field:wizard.partner.cc.iban,id:0
142+msgid "ID"
143+msgstr "ID"
144+
145+#. module: l10n_es_iban_converter
146+#: field:wizard.partner.cc.iban,write_uid:0
147+msgid "Last Updated by"
148+msgstr "Actualizado por"
149+
150+#. module: l10n_es_iban_converter
151+#: field:wizard.partner.cc.iban,write_date:0
152+msgid "Last Updated on"
153+msgstr "Actualizado el"
154+
155+#. module: l10n_es_iban_converter
156+#: model:ir.model,name:l10n_es_iban_converter.model_wizard_partner_cc_iban
157+msgid "Wizard Partner CC IBAN"
158+msgstr "Wizard Partner CC IBAN"
159+
160+#. module: l10n_es_iban_converter
161+#: view:wizard.partner.cc.iban:0
162+msgid "You are going to update account number in partners banks, select which type to do you want to change"
163+msgstr "Va a actualizar los nĂºmeros de cuenta, elija el tipo de cuenta al que quiere cambiar"
164+
165+#. module: l10n_es_iban_converter
166+#: view:wizard.partner.cc.iban:0
167+msgid "or"
168+msgstr "o"
169+
170
171=== added file 'l10n_es_iban_converter/i18n/l10n_es_iban_converter.pot'
172--- l10n_es_iban_converter/i18n/l10n_es_iban_converter.pot 1970-01-01 00:00:00 +0000
173+++ l10n_es_iban_converter/i18n/l10n_es_iban_converter.pot 2014-08-05 10:25:46 +0000
174@@ -0,0 +1,83 @@
175+# Translation of Odoo Server.
176+# This file contains the translation of the following modules:
177+# * l10n_es_iban_converter
178+#
179+msgid ""
180+msgstr ""
181+"Project-Id-Version: Odoo Server 8.0rc1\n"
182+"Report-Msgid-Bugs-To: \n"
183+"POT-Creation-Date: 2014-08-04 14:05+0000\n"
184+"PO-Revision-Date: 2014-08-04 14:05+0000\n"
185+"Last-Translator: <>\n"
186+"Language-Team: \n"
187+"MIME-Version: 1.0\n"
188+"Content-Type: text/plain; charset=UTF-8\n"
189+"Content-Transfer-Encoding: \n"
190+"Plural-Forms: \n"
191+
192+#. module: l10n_es_iban_converter
193+#: field:wizard.partner.cc.iban,bank_state:0
194+msgid "Bank Account Type"
195+msgstr ""
196+
197+#. module: l10n_es_iban_converter
198+#: model:ir.model,name:l10n_es_iban_converter.model_res_partner_bank
199+msgid "Bank Accounts"
200+msgstr ""
201+
202+#. module: l10n_es_iban_converter
203+#: view:wizard.partner.cc.iban:0
204+msgid "Cancel"
205+msgstr ""
206+
207+#. module: l10n_es_iban_converter
208+#: view:wizard.partner.cc.iban:0
209+msgid "Convert"
210+msgstr ""
211+
212+#. module: l10n_es_iban_converter
213+#: model:ir.actions.act_window,name:l10n_es_iban_converter.action_partner_to_cciban
214+#: view:wizard.partner.cc.iban:0
215+msgid "Convert CCC <-> IBAN"
216+msgstr ""
217+
218+#. module: l10n_es_iban_converter
219+#: field:wizard.partner.cc.iban,create_uid:0
220+msgid "Created by"
221+msgstr ""
222+
223+#. module: l10n_es_iban_converter
224+#: field:wizard.partner.cc.iban,create_date:0
225+msgid "Created on"
226+msgstr ""
227+
228+#. module: l10n_es_iban_converter
229+#: field:wizard.partner.cc.iban,id:0
230+msgid "ID"
231+msgstr ""
232+
233+#. module: l10n_es_iban_converter
234+#: field:wizard.partner.cc.iban,write_uid:0
235+msgid "Last Updated by"
236+msgstr ""
237+
238+#. module: l10n_es_iban_converter
239+#: field:wizard.partner.cc.iban,write_date:0
240+msgid "Last Updated on"
241+msgstr ""
242+
243+#. module: l10n_es_iban_converter
244+#: model:ir.model,name:l10n_es_iban_converter.model_wizard_partner_cc_iban
245+msgid "Wizard Partner CC IBAN"
246+msgstr ""
247+
248+#. module: l10n_es_iban_converter
249+#: view:wizard.partner.cc.iban:0
250+msgid "You are going to update account number in partners banks, select which type to do you want to change"
251+msgstr ""
252+
253+#. module: l10n_es_iban_converter
254+#: view:wizard.partner.cc.iban:0
255+msgid "or"
256+msgstr ""
257+
258
259=== added directory 'l10n_es_iban_converter/views'
260=== added file 'l10n_es_iban_converter/views/res_partner_view_ext.xml'
261--- l10n_es_iban_converter/views/res_partner_view_ext.xml 1970-01-01 00:00:00 +0000
262+++ l10n_es_iban_converter/views/res_partner_view_ext.xml 2014-08-05 10:25:46 +0000
263@@ -0,0 +1,10 @@
264+<?xml version="1.0" encoding="UTF-8"?>
265+<openerp>
266+ <data>
267+ <!-- ACTION partner To CC IBAN -->
268+ <act_window id="action_partner_to_cciban" key2="client_action_multi"
269+ name="Convert CCC &lt;-&gt; IBAN" res_model="wizard.partner.cc.iban"
270+ src_model="res.partner" view_id="wizard_partner_cc_iban_view"
271+ view_mode="form" target="new" view_type="form" />
272+ </data>
273+</openerp>
274\ No newline at end of file
275
276=== added directory 'l10n_es_iban_converter/wizard'
277=== added file 'l10n_es_iban_converter/wizard/__init__.py'
278--- l10n_es_iban_converter/wizard/__init__.py 1970-01-01 00:00:00 +0000
279+++ l10n_es_iban_converter/wizard/__init__.py 2014-08-05 10:25:46 +0000
280@@ -0,0 +1,24 @@
281+# -*- encoding: utf-8 -*-
282+########################################################################
283+#
284+# @authors: Ignacio Ibeas <ignacio@acysos.com>
285+# Copyright (C) 2013 Acysos S.L.
286+#
287+#This program is free software: you can redistribute it and/or modify
288+#it under the terms of the GNU General Public License as published by
289+#the Free Software Foundation, either version 3 of the License, or
290+#(at your option) any later version.
291+#
292+# This module is GPLv3 or newer and incompatible
293+# with OpenERP SA "AGPL + Private Use License"!
294+#
295+#This program is distributed in the hope that it will be useful,
296+#but WITHOUT ANY WARRANTY; without even the implied warranty of
297+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
298+#GNU General Public License for more details.
299+#
300+#You should have received a copy of the GNU General Public License
301+#along with this program. If not, see http://www.gnu.org/licenses.
302+########################################################################
303+
304+from . import wizard_partner_cc_iban
305
306=== added file 'l10n_es_iban_converter/wizard/wizard_partner_cc_iban.py'
307--- l10n_es_iban_converter/wizard/wizard_partner_cc_iban.py 1970-01-01 00:00:00 +0000
308+++ l10n_es_iban_converter/wizard/wizard_partner_cc_iban.py 2014-08-05 10:25:46 +0000
309@@ -0,0 +1,122 @@
310+# -*- encoding: utf-8 -*-
311+########################################################################
312+#
313+# @authors: Ignacio Ibeas <ignacio@acysos.com>
314+# Copyright (C) 2013 Acysos S.L.
315+#
316+#This program is free software: you can redistribute it and/or modify
317+#it under the terms of the GNU General Public License as published by
318+#the Free Software Foundation, either version 3 of the License, or
319+#(at your option) any later version.
320+#
321+# This module is GPLv3 or newer and incompatible
322+# with OpenERP SA "AGPL + Private Use License"!
323+#
324+#This program is distributed in the hope that it will be useful,
325+#but WITHOUT ANY WARRANTY; without even the implied warranty of
326+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
327+#GNU General Public License for more details.
328+#
329+#You should have received a copy of the GNU General Public License
330+#along with this program. If not, see http://www.gnu.org/licenses.
331+########################################################################
332+
333+from openerp.osv import fields, orm
334+
335+from openerp.addons.base_iban.base_iban import _pretty_iban
336+
337+
338+_mapping = {'A': '10', 'B': '11', 'C': '12', 'D': '13', 'E': '14', 'F': '15',
339+ 'G': '16', 'H': '17', 'I': '18', 'J': '19', 'K': '20', 'L': '21',
340+ 'M': '22', 'N': '23', 'O': '24', 'P': '25', 'Q': '26', 'R': '27',
341+ 'S': '28', 'T': '29', 'U': '30', 'V': '31', 'W': '32', 'X': '33',
342+ 'Y': '34', 'Z': '35'}
343+
344+
345+class WizardPartnerCcIban(orm.TransientModel):
346+ _name = "wizard.partner.cc.iban"
347+ _description = "Wizard Partner CC IBAN"
348+
349+ def _bank_type_get(self, cr, uid, context=None):
350+ partner_bank_obj = self.pool['res.partner.bank']
351+ return partner_bank_obj._bank_type_get(cr, uid, context=context)
352+
353+ _columns = {
354+ 'bank_state': fields.selection(_bank_type_get, 'Bank Account Type',
355+ required=True),
356+ }
357+
358+ def update_cc_iban(self, cr, uid, ids, context=None):
359+ if context is None:
360+ context = {}
361+ data = self.read(cr, uid, ids, context=context)[0]
362+ bank_obj = self.pool['res.partner.bank']
363+ partner_obj = self.pool['res.partner']
364+ partner_ids = context.get('active_ids')
365+ if partner_ids:
366+ for partner in partner_obj.browse(cr, uid, partner_ids,
367+ context=context):
368+ if partner.bank_ids:
369+ for bank in partner.bank_ids:
370+ new_data = {}
371+ country = bank.country_id
372+ if not country:
373+ country = partner.country_id
374+ new_data['country_id'] = country.id
375+ if bank.state == data['bank_state']:
376+ continue
377+ if bank.state == 'bank':
378+ iban = self.convert_to_iban(cr, uid,
379+ bank.acc_number,
380+ country.code,
381+ context=context)
382+ values = bank_obj.onchange_banco(cr, uid, ids,
383+ iban, country.id,
384+ 'iban',
385+ context=context)
386+ new_data.update(
387+ {'acc_number': values['value']['acc_number'],
388+ 'state': 'iban'})
389+ elif bank.state == 'iban':
390+ ccc = self.convert_to_ccc(cr, uid, bank.acc_number,
391+ context=context)
392+ values = bank_obj.onchange_banco(cr, uid, ids, ccc,
393+ country.id,
394+ 'bank',
395+ context=context)
396+ new_data.update(
397+ {'acc_number': values['value']['acc_number'],
398+ 'state': 'bank'})
399+ if (not bank.bank or not bank.bank_bic) and \
400+ 'bank' in values['value']:
401+ bank_data = bank_obj.onchange_bank_id(
402+ cr, uid, ids, values['value']['bank'],
403+ context=context)
404+ new_data.update(
405+ {'bank': values['value']['bank'],
406+ 'bank_bic': bank_data['value']['bank_bic'],
407+ 'bank_name': bank_data['value']['bank_name']})
408+ bank_obj.write(cr, uid, [bank.id], new_data,
409+ context=context)
410+ return {'type': 'ir.actions.act_window_close'}
411+
412+ def convert_to_iban(self, cr, uid, acc_number, country_code, context=None):
413+ code_char = _mapping[country_code[:1]] + _mapping[country_code[1:]]
414+ ccc = acc_number.replace(" ", "")
415+ for key, replacement in _mapping.items():
416+ ccc_number = ccc.replace(key, replacement)
417+ ccc_convert = int(ccc_number + code_char + '00')
418+ remainder = ccc_convert % 97
419+ control_digit = 98 - remainder
420+ if control_digit < 10:
421+ control_digit = '0' + str(control_digit)
422+ else:
423+ control_digit = str(control_digit)
424+ iban = _pretty_iban(country_code + control_digit + str(ccc))
425+ return iban
426+
427+ def convert_to_ccc(self, cr, uid, acc_number, context=None):
428+ ccc = acc_number.replace(" ", "")
429+ acc_number = ccc[4:]
430+ return "%s %s %s %s" % (acc_number[0:4], acc_number[4:8],
431+ acc_number[8:10], acc_number[10:])
432
433=== added file 'l10n_es_iban_converter/wizard/wizard_partner_cc_iban_view.xml'
434--- l10n_es_iban_converter/wizard/wizard_partner_cc_iban_view.xml 1970-01-01 00:00:00 +0000
435+++ l10n_es_iban_converter/wizard/wizard_partner_cc_iban_view.xml 2014-08-05 10:25:46 +0000
436@@ -0,0 +1,31 @@
437+<?xml version="1.0" encoding="UTF-8"?>
438+<openerp>
439+ <data>
440+
441+ <record id="wizard_partner_cc_iban_view" model="ir.ui.view">
442+ <field name="name">wizard.partner.cc.iban.view</field>
443+ <field name="model">wizard.partner.cc.iban</field>
444+ <field name="type">form</field>
445+ <field name="arch" type="xml">
446+ <form string="Convert CCC &lt;-&gt; IBAN" version="7.0">
447+ <group colspan="4">
448+ <separator colspan="4" />
449+ <label
450+ string="You are going to update account number in partners banks, select which type to do you want to change" />
451+ <field name="bank_state" nolabel="1" />
452+ </group>
453+ <footer>
454+ <group colspan="8" col="8">
455+ <button name="update_cc_iban" string="Convert"
456+ type="object" class="oe_highlight" />
457+ or
458+ <button special="cancel" string="Cancel" />
459+ </group>
460+ </footer>
461+
462+ </form>
463+ </field>
464+ </record>
465+
466+ </data>
467+</openerp>
468\ No newline at end of file

Subscribers

People subscribed via source and target branches