Merge lp:~therp-nl/banking-addons/6.1-dev-preserve-domestic into lp:~banking-addons-team/banking-addons/6.1-dev
- 6.1-dev-preserve-domestic
- Merge into 6.1-dev
Proposed by
Stefan Rijnhart (Opener)
Status: | Merged |
---|---|
Approved by: | James Jesudason |
Approved revision: | 109 |
Merge reported by: | James Jesudason |
Merged at revision: | not available |
Proposed branch: | lp:~therp-nl/banking-addons/6.1-dev-preserve-domestic |
Merge into: | lp:~banking-addons-team/banking-addons/6.1-dev |
Diff against target: |
598 lines (+241/-104) 10 files modified
account_banking/__openerp__.py (+5/-1) account_banking/account_banking.py (+90/-63) account_banking/account_banking_view.xml (+27/-16) account_banking/banking_import_transaction.py (+1/-1) account_banking/data/account_banking_data.xml (+0/-18) account_banking/wizard/banktools.py (+7/-5) account_iban_preserve_domestic/__init__.py (+1/-0) account_iban_preserve_domestic/__openerp__.py (+61/-0) account_iban_preserve_domestic/res_partner_bank.py (+12/-0) account_iban_preserve_domestic/res_partner_bank_view.xml (+37/-0) |
To merge this branch: | bzr merge lp:~therp-nl/banking-addons/6.1-dev-preserve-domestic |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Jesudason (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Adapt to changes in base_iban: preserve the domestic account number
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_banking/__openerp__.py' | |||
2 | --- account_banking/__openerp__.py 2012-02-01 15:36:09 +0000 | |||
3 | +++ account_banking/__openerp__.py 2012-02-19 21:14:20 +0000 | |||
4 | @@ -35,7 +35,8 @@ | |||
5 | 35 | 'author': 'Banking addons community', | 35 | 'author': 'Banking addons community', |
6 | 36 | 'website': 'https://launchpad.net/banking-addons', | 36 | 'website': 'https://launchpad.net/banking-addons', |
7 | 37 | 'category': 'Banking addons', | 37 | 'category': 'Banking addons', |
9 | 38 | 'depends': ['base', 'account', 'base_iban', 'account_payment'], | 38 | 'depends': ['base', 'account', 'base_iban', 'account_payment', |
10 | 39 | 'account_iban_preserve_domestic'], | ||
11 | 39 | 'init_xml': [], | 40 | 'init_xml': [], |
12 | 40 | 'update_xml': [ | 41 | 'update_xml': [ |
13 | 41 | 'security/ir.model.access.csv', | 42 | 'security/ir.model.access.csv', |
14 | @@ -47,6 +48,9 @@ | |||
15 | 47 | 'workflow/account_invoice.xml', | 48 | 'workflow/account_invoice.xml', |
16 | 48 | ], | 49 | ], |
17 | 49 | 'demo_xml': [], | 50 | 'demo_xml': [], |
18 | 51 | 'external_dependencies': { | ||
19 | 52 | 'python' : ['BeautifulSoup'], | ||
20 | 53 | }, | ||
21 | 50 | 'description': ''' | 54 | 'description': ''' |
22 | 51 | Module to do banking. | 55 | Module to do banking. |
23 | 52 | 56 | ||
24 | 53 | 57 | ||
25 | === modified file 'account_banking/account_banking.py' | |||
26 | --- account_banking/account_banking.py 2012-02-17 23:36:43 +0000 | |||
27 | +++ account_banking/account_banking.py 2012-02-19 21:14:20 +0000 | |||
28 | @@ -66,6 +66,7 @@ | |||
29 | 66 | import decimal_precision as dp | 66 | import decimal_precision as dp |
30 | 67 | import pooler | 67 | import pooler |
31 | 68 | import netsvc | 68 | import netsvc |
32 | 69 | from openerp import SUPERUSER_ID | ||
33 | 69 | 70 | ||
34 | 70 | def warning(title, message): | 71 | def warning(title, message): |
35 | 71 | '''Convenience routine''' | 72 | '''Convenience routine''' |
36 | @@ -1070,11 +1071,6 @@ | |||
37 | 1070 | using IBAN specs. | 1071 | using IBAN specs. |
38 | 1071 | ''' | 1072 | ''' |
39 | 1072 | _inherit = 'res.partner.bank' | 1073 | _inherit = 'res.partner.bank' |
40 | 1073 | _columns = { | ||
41 | 1074 | 'iban': fields.char('IBAN', size=34, | ||
42 | 1075 | help="International Bank Account Number" | ||
43 | 1076 | ), | ||
44 | 1077 | } | ||
45 | 1078 | 1074 | ||
46 | 1079 | def __init__(self, *args, **kwargs): | 1075 | def __init__(self, *args, **kwargs): |
47 | 1080 | ''' | 1076 | ''' |
48 | @@ -1091,61 +1087,64 @@ | |||
49 | 1091 | self._founder = mro[i] | 1087 | self._founder = mro[i] |
50 | 1092 | break | 1088 | break |
51 | 1093 | 1089 | ||
53 | 1094 | def init(self, cursor): | 1090 | def init(self, cr): |
54 | 1095 | ''' | 1091 | ''' |
55 | 1096 | Update existing iban accounts to comply to new regime | 1092 | Update existing iban accounts to comply to new regime |
56 | 1097 | Note that usage of the ORM is not possible here, as the ORM cannot | 1093 | Note that usage of the ORM is not possible here, as the ORM cannot |
57 | 1098 | search on values not provided by the client. | 1094 | search on values not provided by the client. |
58 | 1099 | ''' | 1095 | ''' |
69 | 1100 | cursor.execute('SELECT id, acc_number, iban ' | 1096 | |
70 | 1101 | 'FROM res_partner_bank ' | 1097 | partner_bank_obj = self.pool.get('res.partner.bank') |
71 | 1102 | 'WHERE ' | 1098 | bank_ids = partner_bank_obj.search( |
72 | 1103 | 'upper(iban) != iban OR ' | 1099 | cr, SUPERUSER_ID, [('state', '=', 'iban')], limit=0) |
73 | 1104 | 'acc_number IS NULL' | 1100 | for bank in partner_bank_obj.read(cr, SUPERUSER_ID, bank_ids): |
74 | 1105 | ) | 1101 | write_vals = {} |
75 | 1106 | for id, acc_number, iban in cursor.fetchall(): | 1102 | if bank['state'] == 'iban': |
76 | 1107 | new_iban = new_acc_number = False | 1103 | iban_acc = sepa.IBAN(bank['acc_number']) |
67 | 1108 | if iban: | ||
68 | 1109 | iban_acc = sepa.IBAN(iban) | ||
77 | 1110 | if iban_acc.valid: | 1104 | if iban_acc.valid: |
88 | 1111 | new_acc_number = iban_acc.localized_BBAN | 1105 | write_vals['acc_number_domestic'] = iban_acc.localized_BBAN |
89 | 1112 | new_iban = str(iban_acc) | 1106 | write_vals['acc_number'] = str(iban_acc) |
90 | 1113 | elif iban != iban.upper(): | 1107 | elif bank['acc_number'] != bank['acc_number'].upper(): |
91 | 1114 | new_iban = iban.upper | 1108 | write_vals['acc_number'] = bank['acc_number'].upper() |
92 | 1115 | if iban != new_iban or new_acc_number != acc_number: | 1109 | if write_vals: |
93 | 1116 | cursor.execute("UPDATE res_partner_bank " | 1110 | partner_bank_obj.write( |
94 | 1117 | "SET iban = '%s', acc_number = '%s' " | 1111 | cr, SUPERUSER_ID, bank['id'], write_vals) |
85 | 1118 | "WHERE id = %s" % ( | ||
86 | 1119 | new_iban, new_acc_number, id | ||
87 | 1120 | )) | ||
95 | 1121 | 1112 | ||
96 | 1122 | @staticmethod | 1113 | @staticmethod |
98 | 1123 | def _correct_IBAN(vals): | 1114 | def _correct_IBAN(acc_number): |
99 | 1124 | ''' | 1115 | ''' |
100 | 1125 | Routine to correct IBAN values and deduce localized values when valid. | 1116 | Routine to correct IBAN values and deduce localized values when valid. |
101 | 1126 | Note: No check on validity IBAN/Country | 1117 | Note: No check on validity IBAN/Country |
102 | 1127 | ''' | 1118 | ''' |
108 | 1128 | if 'iban' in vals and vals['iban']: | 1119 | iban = sepa.IBAN(acc_number) |
109 | 1129 | iban = sepa.IBAN(vals['iban']) | 1120 | return (str(iban), iban.localized_BBAN) |
105 | 1130 | vals['iban'] = str(iban) | ||
106 | 1131 | vals['acc_number'] = iban.localized_BBAN | ||
107 | 1132 | return vals | ||
110 | 1133 | 1121 | ||
111 | 1134 | def create(self, cursor, uid, vals, context=None): | 1122 | def create(self, cursor, uid, vals, context=None): |
112 | 1135 | ''' | 1123 | ''' |
113 | 1136 | Create dual function IBAN account for SEPA countries | 1124 | Create dual function IBAN account for SEPA countries |
114 | 1137 | ''' | 1125 | ''' |
118 | 1138 | return self._founder.create(cursor, uid, | 1126 | if vals['state'] == 'iban': |
119 | 1139 | self._correct_IBAN(vals), context | 1127 | vals['acc_number'], vals['acc_number_domestic'] = ( |
120 | 1140 | ) | 1128 | self._correct_IBAN(vals['acc_number'])) |
121 | 1129 | return self._founder.create(cursor, uid, vals, context) | ||
122 | 1141 | 1130 | ||
124 | 1142 | def write(self, cursor, uid, ids, vals, context=None): | 1131 | def write(self, cr, uid, ids, vals, context=None): |
125 | 1143 | ''' | 1132 | ''' |
126 | 1144 | Create dual function IBAN account for SEPA countries | 1133 | Create dual function IBAN account for SEPA countries |
127 | 1145 | ''' | 1134 | ''' |
131 | 1146 | return self._founder.write(cursor, uid, ids, | 1135 | if ids and isinstance(ids, (int, long)): |
132 | 1147 | self._correct_IBAN(vals), context | 1136 | ids = [ids] |
133 | 1148 | ) | 1137 | for account in self.read( |
134 | 1138 | cr, uid, ids, ['state', 'acc_number']): | ||
135 | 1139 | if 'state' in vals or 'acc_number' in vals: | ||
136 | 1140 | account.update(vals) | ||
137 | 1141 | if 'state' in vals and vals['state'] == 'iban': | ||
138 | 1142 | vals['acc_number'], vals['acc_number_domestic'] = ( | ||
139 | 1143 | self._correct_IBAN(account['acc_number'])) | ||
140 | 1144 | else: | ||
141 | 1145 | vals['acc_number_domestic'] = False | ||
142 | 1146 | self._founder.write(cr, uid, account['id'], vals, context) | ||
143 | 1147 | return True | ||
144 | 1149 | 1148 | ||
145 | 1150 | def search(self, cursor, uid, args, *rest, **kwargs): | 1149 | def search(self, cursor, uid, args, *rest, **kwargs): |
146 | 1151 | ''' | 1150 | ''' |
147 | @@ -1167,7 +1166,7 @@ | |||
148 | 1167 | Extend the search criteria in term when appropriate. | 1166 | Extend the search criteria in term when appropriate. |
149 | 1168 | ''' | 1167 | ''' |
150 | 1169 | extra_term = None | 1168 | extra_term = None |
152 | 1170 | if term[0].lower() == 'iban' and term[1] in ('=', '=='): | 1169 | if term[0].lower() == 'acc_number' and term[1] in ('=', '=='): |
153 | 1171 | iban = sepa.IBAN(term[2]) | 1170 | iban = sepa.IBAN(term[2]) |
154 | 1172 | if iban.valid: | 1171 | if iban.valid: |
155 | 1173 | # Some countries can't convert to BBAN | 1172 | # Some countries can't convert to BBAN |
156 | @@ -1175,7 +1174,7 @@ | |||
157 | 1175 | bban = iban.localized_BBAN | 1174 | bban = iban.localized_BBAN |
158 | 1176 | # Prevent empty search filters | 1175 | # Prevent empty search filters |
159 | 1177 | if bban: | 1176 | if bban: |
161 | 1178 | extra_term = ('acc_number', term[1], bban) | 1177 | extra_term = ('acc_number_domestic', term[1], bban) |
162 | 1179 | except: | 1178 | except: |
163 | 1180 | pass | 1179 | pass |
164 | 1181 | if extra_term: | 1180 | if extra_term: |
165 | @@ -1212,25 +1211,33 @@ | |||
166 | 1212 | ) | 1211 | ) |
167 | 1213 | return results | 1212 | return results |
168 | 1214 | 1213 | ||
170 | 1215 | def read(self, *args, **kwargs): | 1214 | def read( |
171 | 1215 | self, cr, uid, ids, fields=None, context=None, load='_classic_read'): | ||
172 | 1216 | ''' | 1216 | ''' |
173 | 1217 | Convert IBAN electronic format to IBAN display format | 1217 | Convert IBAN electronic format to IBAN display format |
174 | 1218 | SR 2012-02-19: do we really need this? Fields are converted upon write already. | ||
175 | 1218 | ''' | 1219 | ''' |
177 | 1219 | records = self._founder.read(*args, **kwargs) | 1220 | if fields and 'state' not in fields: |
178 | 1221 | fields.append('state') | ||
179 | 1222 | records = self._founder.read(cr, uid, ids, fields, context, load) | ||
180 | 1223 | is_list = True | ||
181 | 1220 | if not isinstance(records, list): | 1224 | if not isinstance(records, list): |
182 | 1221 | records = [records,] | 1225 | records = [records,] |
183 | 1226 | is_list = False | ||
184 | 1222 | for record in records: | 1227 | for record in records: |
188 | 1223 | if 'iban' in record and record['iban']: | 1228 | if 'acc_number' in record and record['state'] == 'iban': |
189 | 1224 | record['iban'] = unicode(sepa.IBAN(record['iban'])) | 1229 | record['acc_number'] = unicode(sepa.IBAN(record['acc_number'])) |
190 | 1225 | return records | 1230 | if is_list: |
191 | 1231 | return records | ||
192 | 1232 | return records[0] | ||
193 | 1226 | 1233 | ||
194 | 1227 | def check_iban(self, cursor, uid, ids): | 1234 | def check_iban(self, cursor, uid, ids): |
195 | 1228 | ''' | 1235 | ''' |
196 | 1229 | Check IBAN number | 1236 | Check IBAN number |
197 | 1230 | ''' | 1237 | ''' |
198 | 1231 | for bank_acc in self.browse(cursor, uid, ids): | 1238 | for bank_acc in self.browse(cursor, uid, ids): |
201 | 1232 | if bank_acc.iban: | 1239 | if bank_acc.state == 'iban' and bank_acc.acc_number: |
202 | 1233 | iban = sepa.IBAN(bank_acc.iban) | 1240 | iban = sepa.IBAN(bank_acc.acc_number) |
203 | 1234 | if not iban.valid: | 1241 | if not iban.valid: |
204 | 1235 | return False | 1242 | return False |
205 | 1236 | return True | 1243 | return True |
206 | @@ -1241,19 +1248,33 @@ | |||
207 | 1241 | ''' | 1248 | ''' |
208 | 1242 | res = {} | 1249 | res = {} |
209 | 1243 | for record in self.browse(cursor, uid, ids, context): | 1250 | for record in self.browse(cursor, uid, ids, context): |
211 | 1244 | if not record.iban: | 1251 | if not record.state == 'iban': |
212 | 1245 | res[record.id] = False | 1252 | res[record.id] = False |
213 | 1246 | else: | 1253 | else: |
215 | 1247 | iban_acc = sepa.IBAN(record.iban) | 1254 | iban_acc = sepa.IBAN(record.acc_number) |
216 | 1248 | try: | 1255 | try: |
217 | 1249 | res[record.id] = iban_acc.localized_BBAN | 1256 | res[record.id] = iban_acc.localized_BBAN |
218 | 1250 | except NotImplementedError: | 1257 | except NotImplementedError: |
219 | 1251 | res[record.id] = False | 1258 | res[record.id] = False |
220 | 1252 | return res | 1259 | return res |
221 | 1253 | 1260 | ||
225 | 1254 | def onchange_acc_number(self, cursor, uid, ids, acc_number, | 1261 | def onchange_acc_number( |
226 | 1255 | partner_id, country_id, context=None | 1262 | self, cr, uid, ids, acc_number, acc_number_domestic, |
227 | 1256 | ): | 1263 | state, partner_id, country_id, context=None): |
228 | 1264 | if state == 'iban': | ||
229 | 1265 | return self.onchange_iban( | ||
230 | 1266 | cr, uid, ids, acc_number, acc_number_domestic, | ||
231 | 1267 | state, partner_id, country_id, context=None | ||
232 | 1268 | ) | ||
233 | 1269 | else: | ||
234 | 1270 | return self.onchange_domestic( | ||
235 | 1271 | cr, uid, ids, acc_number, | ||
236 | 1272 | partner_id, country_id, context=None | ||
237 | 1273 | ) | ||
238 | 1274 | |||
239 | 1275 | def onchange_domestic( | ||
240 | 1276 | self, cursor, uid, ids, acc_number, | ||
241 | 1277 | partner_id, country_id, context=None): | ||
242 | 1257 | ''' | 1278 | ''' |
243 | 1258 | Trigger to find IBAN. When found: | 1279 | Trigger to find IBAN. When found: |
244 | 1259 | 1. Reformat BBAN | 1280 | 1. Reformat BBAN |
245 | @@ -1314,14 +1335,18 @@ | |||
246 | 1314 | ) | 1335 | ) |
247 | 1315 | result = {'value': values} | 1336 | result = {'value': values} |
248 | 1316 | # Complete data with online database when available | 1337 | # Complete data with online database when available |
250 | 1317 | if partner_id and country.code in sepa.IBAN.countries: | 1338 | if country_ids: |
251 | 1339 | country = country_obj.browse( | ||
252 | 1340 | cursor, uid, country_ids[0], context=context) | ||
253 | 1341 | if country and country.code in sepa.IBAN.countries: | ||
254 | 1318 | try: | 1342 | try: |
255 | 1319 | info = sepa.online.account_info(country.code, acc_number) | 1343 | info = sepa.online.account_info(country.code, acc_number) |
256 | 1320 | if info: | 1344 | if info: |
257 | 1321 | iban_acc = sepa.IBAN(info.iban) | 1345 | iban_acc = sepa.IBAN(info.iban) |
258 | 1322 | if iban_acc.valid: | 1346 | if iban_acc.valid: |
261 | 1323 | values['acc_number'] = iban_acc.localized_BBAN | 1347 | values['acc_number_domestic'] = iban_acc.localized_BBAN |
262 | 1324 | values['iban'] = unicode(iban_acc) | 1348 | values['acc_number'] = unicode(iban_acc) |
263 | 1349 | values['state'] = 'iban' | ||
264 | 1325 | bank_id, country_id = get_or_create_bank( | 1350 | bank_id, country_id = get_or_create_bank( |
265 | 1326 | self.pool, cursor, uid, | 1351 | self.pool, cursor, uid, |
266 | 1327 | info.bic or iban_acc.BIC_searchkey, | 1352 | info.bic or iban_acc.BIC_searchkey, |
267 | @@ -1355,25 +1380,27 @@ | |||
268 | 1355 | values['acc_number'] = acc_number | 1380 | values['acc_number'] = acc_number |
269 | 1356 | return result | 1381 | return result |
270 | 1357 | 1382 | ||
272 | 1358 | def onchange_iban(self, cursor, uid, ids, iban, context=None): | 1383 | def onchange_iban( |
273 | 1384 | self, cr, uid, ids, acc_number, acc_number_domestic, | ||
274 | 1385 | state, partner_id, country_id, context=None): | ||
275 | 1359 | ''' | 1386 | ''' |
276 | 1360 | Trigger to verify IBAN. When valid: | 1387 | Trigger to verify IBAN. When valid: |
277 | 1361 | 1. Extract BBAN as local account | 1388 | 1. Extract BBAN as local account |
278 | 1362 | 2. Auto complete bank | 1389 | 2. Auto complete bank |
279 | 1363 | ''' | 1390 | ''' |
281 | 1364 | if not iban: | 1391 | if not acc_number: |
282 | 1365 | return {} | 1392 | return {} |
283 | 1366 | 1393 | ||
285 | 1367 | iban_acc = sepa.IBAN(iban) | 1394 | iban_acc = sepa.IBAN(acc_number) |
286 | 1368 | if iban_acc.valid: | 1395 | if iban_acc.valid: |
287 | 1369 | bank_id, country_id = get_or_create_bank( | 1396 | bank_id, country_id = get_or_create_bank( |
289 | 1370 | self.pool, cursor, uid, iban_acc.BIC_searchkey, | 1397 | self.pool, cr, uid, iban_acc.BIC_searchkey, |
290 | 1371 | code=iban_acc.BIC_searchkey | 1398 | code=iban_acc.BIC_searchkey |
291 | 1372 | ) | 1399 | ) |
292 | 1373 | return { | 1400 | return { |
293 | 1374 | 'value': dict( | 1401 | 'value': dict( |
296 | 1375 | acc_number = iban_acc.localized_BBAN, | 1402 | acc_number_domestic = iban_acc.localized_BBAN, |
297 | 1376 | iban = unicode(iban_acc), | 1403 | acc_number = unicode(iban_acc), |
298 | 1377 | country = country_id or False, | 1404 | country = country_id or False, |
299 | 1378 | bank = bank_id or False, | 1405 | bank = bank_id or False, |
300 | 1379 | ) | 1406 | ) |
301 | @@ -1383,7 +1410,7 @@ | |||
302 | 1383 | ) | 1410 | ) |
303 | 1384 | 1411 | ||
304 | 1385 | _constraints = [ | 1412 | _constraints = [ |
306 | 1386 | (check_iban, _("The IBAN number doesn't seem to be correct"), ["iban"]) | 1413 | (check_iban, _("The IBAN number doesn't seem to be correct"), ["acc_number"]) |
307 | 1387 | ] | 1414 | ] |
308 | 1388 | 1415 | ||
309 | 1389 | res_partner_bank() | 1416 | res_partner_bank() |
310 | 1390 | 1417 | ||
311 | === modified file 'account_banking/account_banking_view.xml' | |||
312 | --- account_banking/account_banking_view.xml 2012-02-17 23:36:43 +0000 | |||
313 | +++ account_banking/account_banking_view.xml 2012-02-19 21:14:20 +0000 | |||
314 | @@ -371,13 +371,16 @@ | |||
315 | 371 | <field name="model">res.partner.bank</field> | 371 | <field name="model">res.partner.bank</field> |
316 | 372 | <field name="inherit_id" ref="base.view_partner_bank_form"/> | 372 | <field name="inherit_id" ref="base.view_partner_bank_form"/> |
317 | 373 | <field name="type">form</field> | 373 | <field name="type">form</field> |
318 | 374 | <field name="priority" eval="24"/> | ||
319 | 374 | <field name="arch" type="xml"> | 375 | <field name="arch" type="xml"> |
326 | 375 | <field name="acc_number" position="replace"> | 376 | <data> |
327 | 376 | <field name="acc_number" on_change="onchange_acc_number(acc_number, partner_id, country_id)"/> | 377 | <field name="acc_number" position="attributes"> |
328 | 377 | <newline /> | 378 | <attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute> |
329 | 378 | <field name="iban" on_change="onchange_iban(iban)" /> | 379 | </field> |
330 | 379 | <newline /> | 380 | <field name="acc_number_domestic" position="attributes"> |
331 | 380 | </field> | 381 | <attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute> |
332 | 382 | </field> | ||
333 | 383 | </data> | ||
334 | 381 | </field> | 384 | </field> |
335 | 382 | </record> | 385 | </record> |
336 | 383 | 386 | ||
337 | @@ -397,26 +400,34 @@ | |||
338 | 397 | <field name="name">res.partner.form.banking-2</field> | 400 | <field name="name">res.partner.form.banking-2</field> |
339 | 398 | <field name="model">res.partner</field> | 401 | <field name="model">res.partner</field> |
340 | 399 | <field name="inherit_id" ref="account.view_partner_property_form"/> | 402 | <field name="inherit_id" ref="account.view_partner_property_form"/> |
341 | 403 | <field name="priority" eval="24"/> | ||
342 | 400 | <field name="type">form</field> | 404 | <field name="type">form</field> |
343 | 401 | <field name="arch" type="xml"> | 405 | <field name="arch" type="xml"> |
350 | 402 | <xpath expr="/form/notebook/page/field[@name='bank_ids']/form/field[@name='acc_number']" position="replace"> | 406 | <data> |
351 | 403 | <field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" /> | 407 | <field name="acc_number" position="attributes"> |
352 | 404 | <newline /> | 408 | <attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute> |
353 | 405 | <field name="iban" on_change="onchange_iban(iban)" /> | 409 | </field> |
354 | 406 | <newline /> | 410 | <field name="acc_number_domestic" position="attributes"> |
355 | 407 | </xpath> | 411 | <attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute> |
356 | 412 | </field> | ||
357 | 413 | </data> | ||
358 | 408 | </field> | 414 | </field> |
359 | 409 | </record> | 415 | </record> |
360 | 410 | <record id="view_partner_account_banking_form_3" model="ir.ui.view"> | 416 | <record id="view_partner_account_banking_form_3" model="ir.ui.view"> |
361 | 411 | <field name="name">res.partner.form.banking-3</field> | 417 | <field name="name">res.partner.form.banking-3</field> |
362 | 412 | <field name="model">res.partner</field> | 418 | <field name="model">res.partner</field> |
363 | 413 | <field name="inherit_id" ref="account.view_partner_property_form"/> | 419 | <field name="inherit_id" ref="account.view_partner_property_form"/> |
364 | 420 | <field name="priority" eval="24"/> | ||
365 | 414 | <field name="type">form</field> | 421 | <field name="type">form</field> |
366 | 415 | <field name="arch" type="xml"> | 422 | <field name="arch" type="xml"> |
371 | 416 | <xpath expr="/form/notebook/page/field[@name='bank_ids']/tree/field[@name='acc_number']" position="replace"> | 423 | <data> |
372 | 417 | <field name="acc_number" on_change="onchange_acc_number(acc_number, parent.id, country_id)" select="1" /> | 424 | <field name="acc_number" position="attributes"> |
373 | 418 | <field name="iban" on_change="onchange_iban(iban)" /> | 425 | <attribute name="on_change">onchange_acc_number(acc_number, acc_number_domestic, state, partner_id, country_id)</attribute> |
374 | 419 | </xpath> | 426 | </field> |
375 | 427 | <field name="acc_number_domestic" position="attributes"> | ||
376 | 428 | <attribute name="on_change">onchange_domestic(acc_number_domestic, partner_id, country_id)</attribute> | ||
377 | 429 | </field> | ||
378 | 430 | </data> | ||
379 | 420 | </field> | 431 | </field> |
380 | 421 | </record> | 432 | </record> |
381 | 422 | 433 | ||
382 | 423 | 434 | ||
383 | === modified file 'account_banking/banking_import_transaction.py' | |||
384 | --- account_banking/banking_import_transaction.py 2012-02-17 23:36:43 +0000 | |||
385 | +++ account_banking/banking_import_transaction.py 2012-02-19 21:14:20 +0000 | |||
386 | @@ -905,7 +905,7 @@ | |||
387 | 905 | if x.communication == trans.reference | 905 | if x.communication == trans.reference |
388 | 906 | and round(x.amount, digits) == -round(trans.transferred_amount, digits) | 906 | and round(x.amount, digits) == -round(trans.transferred_amount, digits) |
389 | 907 | and trans.remote_account in (x.bank_id.acc_number, | 907 | and trans.remote_account in (x.bank_id.acc_number, |
391 | 908 | x.bank_id.iban) | 908 | x.bank_id.acc_number_domestic) |
392 | 909 | ] | 909 | ] |
393 | 910 | if len(candidates) == 1: | 910 | if len(candidates) == 1: |
394 | 911 | candidate = candidates[0] | 911 | candidate = candidates[0] |
395 | 912 | 912 | ||
396 | === modified file 'account_banking/data/account_banking_data.xml' | |||
397 | --- account_banking/data/account_banking_data.xml 2012-02-17 23:36:43 +0000 | |||
398 | +++ account_banking/data/account_banking_data.xml 2012-02-19 21:14:20 +0000 | |||
399 | @@ -1,24 +1,6 @@ | |||
400 | 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
401 | 2 | <openerp> | 2 | <openerp> |
402 | 3 | <data> | 3 | <data> |
403 | 4 | <!-- Re-introduce changes that were removed in 6.1 --> | ||
404 | 5 | <record id="bank_iban_field" model="res.partner.bank.type.field"> | ||
405 | 6 | <field name="name">iban</field> | ||
406 | 7 | <field name="bank_type_id" ref="base_iban.bank_iban"/> | ||
407 | 8 | <field eval="True" name="required"/> | ||
408 | 9 | <field eval="False" name="readonly"/> | ||
409 | 10 | </record> | ||
410 | 11 | |||
411 | 12 | <!-- Unset readonly state of acc_number for IBAN accounts. | ||
412 | 13 | Leaving it will make it impossible to deduce BBAN's from any | ||
413 | 14 | client. | ||
414 | 15 | --> | ||
415 | 16 | <record id="bank_acc_number_field" model="res.partner.bank.type.field"> | ||
416 | 17 | <field name="name">acc_number</field> | ||
417 | 18 | <field name="bank_type_id" ref="base_iban.bank_iban"/> | ||
418 | 19 | <field eval="False" name="required"/> | ||
419 | 20 | <field eval="False" name="readonly"/> | ||
420 | 21 | </record> | ||
421 | 22 | <!-- Unset readonly state of country_id for ordinary account. | 4 | <!-- Unset readonly state of country_id for ordinary account. |
422 | 23 | Leaving it will make it impossible to use bank accounts with | 5 | Leaving it will make it impossible to use bank accounts with |
423 | 24 | addresses outside the companies country. | 6 | addresses outside the companies country. |
424 | 25 | 7 | ||
425 | === modified file 'account_banking/wizard/banktools.py' | |||
426 | --- account_banking/wizard/banktools.py 2012-02-17 23:36:43 +0000 | |||
427 | +++ account_banking/wizard/banktools.py 2012-02-19 21:14:20 +0000 | |||
428 | @@ -98,8 +98,10 @@ | |||
429 | 98 | ('acc_number', '=', account_number) | 98 | ('acc_number', '=', account_number) |
430 | 99 | ]) | 99 | ]) |
431 | 100 | if not bank_account_ids: | 100 | if not bank_account_ids: |
432 | 101 | # SR 2012-02-19 does the search() override in res_partner_bank | ||
433 | 102 | # provides this result on the previous query? | ||
434 | 101 | bank_account_ids = partner_bank_obj.search(cursor, uid, [ | 103 | bank_account_ids = partner_bank_obj.search(cursor, uid, [ |
436 | 102 | ('iban', '=', account_number) | 104 | ('acc_number_domestic', '=', account_number) |
437 | 103 | ]) | 105 | ]) |
438 | 104 | if not bank_account_ids: | 106 | if not bank_account_ids: |
439 | 105 | if not fail: | 107 | if not fail: |
440 | @@ -331,8 +333,8 @@ | |||
441 | 331 | if iban.valid: | 333 | if iban.valid: |
442 | 332 | # Take as much info as possible from IBAN | 334 | # Take as much info as possible from IBAN |
443 | 333 | values.state = 'iban' | 335 | values.state = 'iban' |
446 | 334 | values.iban = str(iban) | 336 | values.acc_number = str(iban) |
447 | 335 | values.acc_number = iban.BBAN | 337 | values.acc_number_domestic = iban.BBAN |
448 | 336 | bankcode = iban.bankcode + iban.countrycode | 338 | bankcode = iban.bankcode + iban.countrycode |
449 | 337 | country_code = iban.countrycode | 339 | country_code = iban.countrycode |
450 | 338 | 340 | ||
451 | @@ -356,13 +358,13 @@ | |||
452 | 356 | if not iban.valid: | 358 | if not iban.valid: |
453 | 357 | # No, try to convert to IBAN | 359 | # No, try to convert to IBAN |
454 | 358 | values.state = 'bank' | 360 | values.state = 'bank' |
456 | 359 | values.acc_number = account_number | 361 | values.acc_number = values.acc_number_domestic = account_number |
457 | 360 | if country_code in sepa.IBAN.countries: | 362 | if country_code in sepa.IBAN.countries: |
458 | 361 | account_info = sepa.online.account_info(country_code, | 363 | account_info = sepa.online.account_info(country_code, |
459 | 362 | values.acc_number | 364 | values.acc_number |
460 | 363 | ) | 365 | ) |
461 | 364 | if account_info: | 366 | if account_info: |
463 | 365 | values.iban = iban = account_info.iban | 367 | values.acc_number = iban = account_info.iban |
464 | 366 | values.state = 'iban' | 368 | values.state = 'iban' |
465 | 367 | bankcode = account_info.code | 369 | bankcode = account_info.code |
466 | 368 | bic = account_info.bic | 370 | bic = account_info.bic |
467 | 369 | 371 | ||
468 | === added directory 'account_iban_preserve_domestic' | |||
469 | === added file 'account_iban_preserve_domestic/__init__.py' | |||
470 | --- account_iban_preserve_domestic/__init__.py 1970-01-01 00:00:00 +0000 | |||
471 | +++ account_iban_preserve_domestic/__init__.py 2012-02-19 21:14:20 +0000 | |||
472 | @@ -0,0 +1,1 @@ | |||
473 | 1 | import res_partner_bank | ||
474 | 0 | 2 | ||
475 | === added file 'account_iban_preserve_domestic/__openerp__.py' | |||
476 | --- account_iban_preserve_domestic/__openerp__.py 1970-01-01 00:00:00 +0000 | |||
477 | +++ account_iban_preserve_domestic/__openerp__.py 2012-02-19 21:14:20 +0000 | |||
478 | @@ -0,0 +1,61 @@ | |||
479 | 1 | ############################################################################## | ||
480 | 2 | # | ||
481 | 3 | # Copyright (C) 2012 Therp BV (<http://therp.nl>). | ||
482 | 4 | # | ||
483 | 5 | # All other contributions are (C) by their respective contributors | ||
484 | 6 | # | ||
485 | 7 | # All Rights Reserved | ||
486 | 8 | # | ||
487 | 9 | # WARNING: This program as such is intended to be used by professional | ||
488 | 10 | # programmers who take the whole responsability of assessing all potential | ||
489 | 11 | # consequences resulting from its eventual inadequacies and bugs | ||
490 | 12 | # End users who are looking for a ready-to-use solution with commercial | ||
491 | 13 | # garantees and support are strongly adviced to contract EduSense BV | ||
492 | 14 | # | ||
493 | 15 | # This program is free software: you can redistribute it and/or modify | ||
494 | 16 | # it under the terms of the GNU General Public License as published by | ||
495 | 17 | # the Free Software Foundation, either version 3 of the License, or | ||
496 | 18 | # (at your option) any later version. | ||
497 | 19 | # | ||
498 | 20 | # This program is distributed in the hope that it will be useful, | ||
499 | 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
500 | 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
501 | 23 | # GNU General Public License for more details. | ||
502 | 24 | # | ||
503 | 25 | # You should have received a copy of the GNU General Public License | ||
504 | 26 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
505 | 27 | # | ||
506 | 28 | ############################################################################## | ||
507 | 29 | { | ||
508 | 30 | 'name': 'Domestic bank account number', | ||
509 | 31 | 'version': '0.1.108', | ||
510 | 32 | 'license': 'AGPL', | ||
511 | 33 | 'author': 'Therp BV', | ||
512 | 34 | 'website': 'https://launchpad.net/banking-addons', | ||
513 | 35 | 'category': 'Banking addons', | ||
514 | 36 | 'depends': ['base_iban','account'], | ||
515 | 37 | 'init_xml': [], | ||
516 | 38 | 'update_xml': [ | ||
517 | 39 | 'res_partner_bank_view.xml' | ||
518 | 40 | ], | ||
519 | 41 | 'demo_xml': [], | ||
520 | 42 | 'description': ''' | ||
521 | 43 | This module is compatible with OpenERP 6.1. | ||
522 | 44 | |||
523 | 45 | The IBAN module in OpenERP 6.1 registers the IBAN | ||
524 | 46 | on the same field as the domestic account number, | ||
525 | 47 | instead of keeping both on separate fields as is the | ||
526 | 48 | case in 6.0. | ||
527 | 49 | |||
528 | 50 | This module adds a field to register the domestic account | ||
529 | 51 | number on IBANs, while the domestic account number is | ||
530 | 52 | still widely in use in certain regions. | ||
531 | 53 | |||
532 | 54 | Note that an upgrade to OpenERP 6.1 makes you lose the | ||
533 | 55 | domestic account numbers on IBANs that were already in | ||
534 | 56 | your system, unless you installed the 6.0 version of this | ||
535 | 57 | module prior to the upgrade to OpenERP 6.1. | ||
536 | 58 | ''', | ||
537 | 59 | 'active': False, | ||
538 | 60 | 'installable': True, | ||
539 | 61 | } | ||
540 | 0 | 62 | ||
541 | === added file 'account_iban_preserve_domestic/res_partner_bank.py' | |||
542 | --- account_iban_preserve_domestic/res_partner_bank.py 1970-01-01 00:00:00 +0000 | |||
543 | +++ account_iban_preserve_domestic/res_partner_bank.py 2012-02-19 21:14:20 +0000 | |||
544 | @@ -0,0 +1,12 @@ | |||
545 | 1 | from osv import fields,osv | ||
546 | 2 | class res_partner_bank(osv.osv): | ||
547 | 3 | ''' Adds a field for domestic account numbers ''' | ||
548 | 4 | _inherit = "res.partner.bank" | ||
549 | 5 | |||
550 | 6 | _columns = { | ||
551 | 7 | 'acc_number_domestic': fields.char( | ||
552 | 8 | 'Domestic Account Number', size=64) | ||
553 | 9 | } | ||
554 | 10 | |||
555 | 11 | res_partner_bank() | ||
556 | 12 | |||
557 | 0 | 13 | ||
558 | === added file 'account_iban_preserve_domestic/res_partner_bank_view.xml' | |||
559 | --- account_iban_preserve_domestic/res_partner_bank_view.xml 1970-01-01 00:00:00 +0000 | |||
560 | +++ account_iban_preserve_domestic/res_partner_bank_view.xml 2012-02-19 21:14:20 +0000 | |||
561 | @@ -0,0 +1,37 @@ | |||
562 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
563 | 2 | <openerp> | ||
564 | 3 | <data> | ||
565 | 4 | |||
566 | 5 | <!-- add the field to the partner bank form, as defined in | ||
567 | 6 | the base module --> | ||
568 | 7 | <record id="view_partner_bank_form" model="ir.ui.view"> | ||
569 | 8 | <field name="name">res.partner.bank.form</field> | ||
570 | 9 | <field name="model">res.partner.bank</field> | ||
571 | 10 | <field name="inherit_id" ref="base.view_partner_bank_form"/> | ||
572 | 11 | <field name="arch" type="xml"> | ||
573 | 12 | <field name="acc_number" position="after"> | ||
574 | 13 | <newline/> | ||
575 | 14 | <field name="acc_number_domestic" | ||
576 | 15 | attrs="{'invisible': [('state', '!=', 'iban')]}" | ||
577 | 16 | /> | ||
578 | 17 | </field> | ||
579 | 18 | </field> | ||
580 | 19 | </record> | ||
581 | 20 | |||
582 | 21 | <!-- add the field to the partner form, as defined in | ||
583 | 22 | the account module --> | ||
584 | 23 | <record id="view_partner_account_form" model="ir.ui.view"> | ||
585 | 24 | <field name="name">res.partner.account.form</field> | ||
586 | 25 | <field name="model">res.partner</field> | ||
587 | 26 | <field name="inherit_id" ref="account.view_partner_property_form"/> | ||
588 | 27 | <field name="arch" type="xml"> | ||
589 | 28 | <field name="acc_number" position="after"> | ||
590 | 29 | <newline/> | ||
591 | 30 | <field name="acc_number_domestic" | ||
592 | 31 | attrs="{'invisible': [('state', '!=', 'iban')]}" | ||
593 | 32 | /> | ||
594 | 33 | </field> | ||
595 | 34 | </field> | ||
596 | 35 | </record> | ||
597 | 36 | </data> | ||
598 | 37 | </openerp> |
The license for preserve domestic module needs to be 'AGPL-3' (not AGPL), otherwise this looks fine.