Merge lp:~pereerro/openerp-spain/l10n_ES_res_partner_bank_checker into lp:~openerp-spain-team/openerp-spain/5.0

Proposed by Pereerro
Status: Rejected
Rejected by: Pedro Manuel Baeza
Proposed branch: lp:~pereerro/openerp-spain/l10n_ES_res_partner_bank_checker
Merge into: lp:~openerp-spain-team/openerp-spain/5.0
Diff against target: 215 lines (+195/-0)
4 files modified
l10n_es_extras/l10n_ES_res_partner_bank_checker/__init__.py (+25/-0)
l10n_es_extras/l10n_ES_res_partner_bank_checker/__openerp__.py (+42/-0)
l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker.py (+79/-0)
l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker_view.xml (+49/-0)
To merge this branch: bzr merge lp:~pereerro/openerp-spain/l10n_ES_res_partner_bank_checker
Reviewer Review Type Date Requested Status
OpenERP Spain Team Pending
Review via email: mp+125276@code.launchpad.net

Description of the change

[IMP] Added two fields that contains information about if the code bank is right.

To post a comment you must log in.
Revision history for this message
mikel (mikel-martin) wrote :

No sé los demás que pensarán pero a mi me parece una funcionalidad que merecería la pena incluirla en l10n_ES_res_partner_bank directamente

Unmerged revisions

234. By Pereerro

[IMP] Added two fields that contains information about if the
    code bank is right.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'l10n_es_extras/l10n_ES_res_partner_bank_checker'
2=== added file 'l10n_es_extras/l10n_ES_res_partner_bank_checker/__init__.py'
3--- l10n_es_extras/l10n_ES_res_partner_bank_checker/__init__.py 1970-01-01 00:00:00 +0000
4+++ l10n_es_extras/l10n_ES_res_partner_bank_checker/__init__.py 2012-09-19 17:05:43 +0000
5@@ -0,0 +1,25 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# account_contact module for OpenERP
10+# Copyright (C) 2010 Tecnoba S.L. (http://www.tecnoba.com)
11+# Pere Ramon Erro Mas <pereerro@tecnoba.com> All Rights Reserved.
12+#
13+# account_contact OpenERP module is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU General Public License as published by
15+# the Free Software Foundation, either version 3 of the License, or
16+# (at your option) any later version.
17+#
18+# school OpenERP module is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU General Public License for more details.
22+#
23+# You should have received a copy of the GNU General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+
28+import res_partner_bank_checker
29+
30+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
31
32=== added file 'l10n_es_extras/l10n_ES_res_partner_bank_checker/__openerp__.py'
33--- l10n_es_extras/l10n_ES_res_partner_bank_checker/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ l10n_es_extras/l10n_ES_res_partner_bank_checker/__openerp__.py 2012-09-19 17:05:43 +0000
35@@ -0,0 +1,42 @@
36+# -*- coding: utf-8 -*-
37+##############################################################################
38+#
39+# res_partner_bank_checker module for OpenERP
40+# Copyright (C) 2010 Tecnoba S.L. (http://www.tecnoba.com)
41+# Pere Ramon Erro Mas <pereerro@tecnoba.com> All Rights Reserved.
42+#
43+#
44+# res_partner_bank_checker OpenERP module is free software: you can redistribute it and/or modify
45+# it under the terms of the GNU General Public License as published by
46+# the Free Software Foundation, either version 3 of the License, or
47+# (at your option) any later version.
48+#
49+# account_contact OpenERP module 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+{
60+ 'name' : 'Checks if the account number is right',
61+ 'version' : '0.0.1',
62+ 'author' : 'Pere Ramon Erro Mas (Tecnoba)',
63+ 'website' : 'http://www.tecnoba.com',
64+ 'description' : """
65+.
66+""",
67+ "category" : "Generic Modules/Others",
68+ "depends": ['base',],
69+ 'demo_xml' : [],
70+ 'update_xml' : [
71+ 'res_partner_bank_checker_view.xml',
72+ ],
73+ 'active' : False,
74+ 'installable' : True,
75+}
76+
77+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
78
79=== added file 'l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker.py'
80--- l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker.py 1970-01-01 00:00:00 +0000
81+++ l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker.py 2012-09-19 17:05:43 +0000
82@@ -0,0 +1,79 @@
83+# -*- coding: utf-8 -*-
84+##############################################################################
85+#
86+# account module for OpenERP
87+# Copyright (C) 2010 Tecnoba S.L. (http://www.tecnoba.com)
88+# Pere Ramon Erro Mas <pereerro@tecnoba.com> All Rights Reserved.
89+#
90+#
91+# account_contact OpenERP module is free software: you can redistribute it and/or modify
92+# it under the terms of the GNU General Public License as published by
93+# the Free Software Foundation, either version 3 of the License, or
94+# (at your option) any later version.
95+#
96+# account_contact OpenERP module is distributed in the hope that it will be useful,
97+# but WITHOUT ANY WARRANTY; without even the implied warranty of
98+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
99+# GNU General Public License for more details.
100+#
101+# You should have received a copy of the GNU General Public License
102+# along with this program. If not, see <http://www.gnu.org/licenses/>.
103+#
104+##############################################################################
105+
106+
107+from osv import osv, fields
108+from datetime import datetime, date, timedelta
109+from tools.translate import _
110+
111+def get_control(ten_digits):
112+ valores = [1, 2, 4, 8, 5, 10, 9, 7, 3, 6];
113+ valor = ten_digits
114+ control = 0;
115+ for i in range(10):
116+ control += int(int(valor[i]) * valores[i])
117+ control = 11 - (control % 11)
118+ if control == 11:
119+ control = 0
120+ elif control == 10:
121+ control = 1
122+ return control;
123+
124+class res_partner_bank(osv.osv):
125+ _name = "res.partner.bank"
126+ _inherit = "res.partner.bank"
127+
128+ def get_acc_es_validation(self, cr, uid, ids, field_name, arg, context=None):
129+ ret = {}
130+ for item in self.browse(cr, uid, ids, context=None):
131+ ret[item.id] = {}
132+ if len(item.acc_number)!=20 or not item.acc_number.isdigit():
133+ ret[item.id]['l10n_es_acc_validation'] = _('The size must be only 20 digits.')
134+ ret[item.id]['l10n_es_acc_valid'] = False
135+ else:
136+ valor = '00'+ item.acc_number[0:8]
137+ d1 = get_control(valor);
138+ if d1 != int(item.acc_number[8]):
139+ ret[item.id]['l10n_es_acc_validation'] = _("Error in bank codes")
140+ ret[item.id]['l10n_es_acc_valid'] = False
141+ else:
142+ valor = item.acc_number[10:20]
143+ d2 = get_control(valor);
144+ if d2 != int(item.acc_number[9]):
145+ ret[item.id]['l10n_es_acc_validation'] = _("Error in last ten digits of account number")
146+ ret[item.id]['l10n_es_acc_valid'] = False
147+ else:
148+ ret[item.id]['l10n_es_acc_validation'] = _("Correct number")
149+ ret[item.id]['l10n_es_acc_valid'] = True
150+ return ret
151+
152+ _columns = {
153+ 'l10n_es_acc_validation' : fields.function(get_acc_es_validation, type='char', multi='l10n_es_acc_validation', method=True, string='l10n_es validation', size=80,),
154+ 'l10n_es_acc_valid' : fields.function(get_acc_es_validation, type='boolean', multi='l10n_es_acc_validation', method=True, string='l10n_es validation',),
155+ }
156+
157+res_partner_bank()
158+
159+
160+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
161+
162
163=== added file 'l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker_view.xml'
164--- l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker_view.xml 1970-01-01 00:00:00 +0000
165+++ l10n_es_extras/l10n_ES_res_partner_bank_checker/res_partner_bank_checker_view.xml 2012-09-19 17:05:43 +0000
166@@ -0,0 +1,49 @@
167+<?xml version="1.0" encoding="UTF-8"?>
168+
169+<openerp>
170+ <data>
171+ <record id="view_partner_bank_form" model="ir.ui.view">
172+ <field name="name">res.partner.bank.l10n_es_validation.form</field>
173+ <field name="model">res.partner.bank</field>
174+ <field name="inherit_id" ref="base.view_partner_bank_form" />
175+ <field name="arch" type="xml">
176+ <xpath expr="/form/field[@name='acc_number']" position="after">
177+ <field name="l10n_es_acc_validation" />
178+ </xpath>
179+ </field>
180+ </record>
181+ <record id="view_partner_form" model="ir.ui.view">
182+ <field name="name">res.partner.bank.l10n_es_validation.form</field>
183+ <field name="model">res.partner</field>
184+ <field name="inherit_id" ref="base.view_partner_form" />
185+ <field name="arch" type="xml">
186+ <xpath expr="/form/notebook/page[@string='Accounting']/field[@name='bank_ids']/form/field[@name='acc_number']" position="after">
187+ <field name="l10n_es_acc_validation" />
188+ </xpath>
189+ </field>
190+ </record>
191+
192+ <record id="view_partner_form2" model="ir.ui.view">
193+ <field name="name">res.partner.bank.l10n_es_validation.form2</field>
194+ <field name="model">res.partner</field>
195+ <field name="inherit_id" ref="base.view_partner_form" />
196+ <field name="arch" type="xml">
197+ <xpath expr="/form/notebook/page[@string='Accounting']/field[@name='bank_ids']/tree/field[@name='acc_number']" position="after">
198+ <field name="l10n_es_acc_valid" />
199+ </xpath>
200+ </field>
201+ </record>
202+ <record id="view_partner_bank_tree" model="ir.ui.view">
203+ <field name="name">res.partner.bank.l10n_es_validation.tree</field>
204+ <field name="model">res.partner.bank</field>
205+ <field name="inherit_id" ref="base.view_partner_bank_tree" />
206+ <field name="arch" type="xml">
207+ <xpath expr="/tree/field[@name='acc_number']" position="after">
208+ <field name="l10n_es_acc_valid" />
209+ </xpath>
210+ </field>
211+ </record>
212+
213+ </data>
214+
215+</openerp>