Merge lp:~acsone-openerp/banking-addons/possible_use_completion_rule_instance into lp:banking-addons/bank-statement-reconcile-70
- possible_use_completion_rule_instance
- Merge into bank-statement-reconcile-70
Status: | Merged |
---|---|
Approved by: | Yannick Vaucher @ Camptocamp |
Approved revision: | 114 |
Merged at revision: | 114 |
Proposed branch: | lp:~acsone-openerp/banking-addons/possible_use_completion_rule_instance |
Merge into: | lp:banking-addons/bank-statement-reconcile-70 |
Diff against target: |
475 lines (+385/-7) 9 files modified
account_statement_base_completion/statement.py (+10/-7) account_statement_regex_account_completion/__init__.py (+32/-0) account_statement_regex_account_completion/__openerp__.py (+56/-0) account_statement_regex_account_completion/i18n/account_statement_regex_account_completion.pot (+32/-0) account_statement_regex_account_completion/i18n/fr.po (+32/-0) account_statement_regex_account_completion/statement.py (+75/-0) account_statement_regex_account_completion/statement_view.xml (+21/-0) account_statement_regex_account_completion/tests/__init__.py (+36/-0) account_statement_regex_account_completion/tests/test_regex_account_completion.py (+91/-0) |
To merge this branch: | bzr merge lp:~acsone-openerp/banking-addons/possible_use_completion_rule_instance |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicolas Bessi - Camptocamp (community) | code review, no test | Approve | |
Stéphane Bidoul (Acsone) (community) | code review and test | Approve | |
Yannick Vaucher @ Camptocamp | code review, no tests | Approve | |
Joël Grand-Guillaume @ camptocamp | code review, no tests | Approve | |
Laurent Mignon (Acsone) (community) | Approve | ||
Review via email: mp+201604@code.launchpad.net |
Commit message
Description of the change
Hello,
in order to use instance of rules I updated the function call parts.
This proposal stay compatible with existing rules. And add id of the rule if the function require more parameter. This id can be usefull to get more parameters to do the completion.
I also add a new module (account_
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote : | # |
Following your suggestion I rename _get_callable in _get_rules (seems better than _get_rule_ids because it is a list of record, not a list of id).
And I correct the number of arguments.
Laurent Mignon (Acsone) (lmi) wrote : | # |
LGTM
A nice feature that shows us how it's now possible to add configurable completion rules!
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Hi,
Thanks for this contribs, seems a good idea to me to add a match with regexp here. LTGM.
Regards,
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
LGTM with last changes
Thanks!
Stéphane Bidoul (Acsone) (sbi) wrote : | # |
Laetitia,
Can you just make the rule name more explicit?
I suggest 'Set account for line labels matching a regular expression' instead of 'Set account'.
Otherwise LGTM.
-sbi
- 115. By Laetitia Gangloff (Acsone)
-
update name of the funtion to 'Set account for line labels matching a regular expression' instead of 'Set account'
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Ok last change is only a string so it has no impact but on the translations that are missing ;)
Can you generate a pot file before I proceed with the merge?
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote : | # |
No problem :)
- 116. By Laetitia Gangloff (Acsone)
-
add translation for account_
statement_ regex_account_ completion module
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
Thanks
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : | # |
LGTM Nice addition to the framework thanks.
Preview Diff
1 | === modified file 'account_statement_base_completion/statement.py' |
2 | --- account_statement_base_completion/statement.py 2013-12-03 15:04:25 +0000 |
3 | +++ account_statement_base_completion/statement.py 2014-01-22 11:18:45 +0000 |
4 | @@ -23,6 +23,7 @@ |
5 | import sys |
6 | import logging |
7 | import simplejson |
8 | +import inspect |
9 | |
10 | import psycopg2 |
11 | |
12 | @@ -73,14 +74,13 @@ |
13 | rel='as_rul_st_prof_rel'), |
14 | } |
15 | |
16 | - def _get_callable(self, cr, uid, profile, context=None): |
17 | + def _get_rules(self, cr, uid, profile, context=None): |
18 | if isinstance(profile, (int, long)): |
19 | prof = self.browse(cr, uid, profile, context=context) |
20 | else: |
21 | prof = profile |
22 | # We need to respect the sequence order |
23 | - sorted_array = sorted(prof.rule_ids, key=attrgetter('sequence')) |
24 | - return tuple((x.function_to_call for x in sorted_array)) |
25 | + return sorted(prof.rule_ids, key=attrgetter('sequence')) |
26 | |
27 | def _find_values_from_rules(self, cr, uid, calls, line, context=None): |
28 | """ |
29 | @@ -99,12 +99,15 @@ |
30 | if context is None: |
31 | context = {} |
32 | if not calls: |
33 | - calls = self._get_callable(cr, uid, line['profile_id'], context=context) |
34 | + calls = self._get_rules(cr, uid, line['profile_id'], context=context) |
35 | rule_obj = self.pool.get('account.statement.completion.rule') |
36 | |
37 | for call in calls: |
38 | - method_to_call = getattr(rule_obj, call) |
39 | - result = method_to_call(cr, uid, line, context) |
40 | + method_to_call = getattr(rule_obj, call.function_to_call) |
41 | + if len(inspect.getargspec(method_to_call).args) == 6: |
42 | + result = method_to_call(cr, uid, call.id, line, context) |
43 | + else: |
44 | + result = method_to_call(cr, uid, line, context) |
45 | if result: |
46 | result['already_completed'] = True |
47 | return result |
48 | @@ -526,7 +529,7 @@ |
49 | ctx = context.copy() |
50 | ctx['line_ids'] = tuple((x.id for x in stat.line_ids)) |
51 | b_profile = stat.profile_id |
52 | - rules = profile_obj._get_callable(cr, uid, b_profile, context=context) |
53 | + rules = profile_obj._get_rules(cr, uid, b_profile, context=context) |
54 | profile_id = b_profile.id # Only for perfo even it gains almost nothing |
55 | master_account_id = b_profile.receivable_account_id |
56 | master_account_id = master_account_id.id if master_account_id else False |
57 | |
58 | === added directory 'account_statement_regex_account_completion' |
59 | === added file 'account_statement_regex_account_completion/__init__.py' |
60 | --- account_statement_regex_account_completion/__init__.py 1970-01-01 00:00:00 +0000 |
61 | +++ account_statement_regex_account_completion/__init__.py 2014-01-22 11:18:45 +0000 |
62 | @@ -0,0 +1,32 @@ |
63 | +# -*- coding: utf-8 -*- |
64 | +############################################################################## |
65 | +# |
66 | +# Authors: Laetitia Gangloff |
67 | +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
68 | +# All Rights Reserved |
69 | +# |
70 | +# WARNING: This program as such is intended to be used by professional |
71 | +# programmers who take the whole responsibility of assessing all potential |
72 | +# consequences resulting from its eventual inadequacies and bugs. |
73 | +# End users who are looking for a ready-to-use solution with commercial |
74 | +# guarantees and support are strongly advised to contact a Free Software |
75 | +# Service Company. |
76 | +# |
77 | +# This program is free software: you can redistribute it and/or modify |
78 | +# it under the terms of the GNU Affero General Public License as |
79 | +# published by the Free Software Foundation, either version 3 of the |
80 | +# License, or (at your option) any later version. |
81 | +# |
82 | +# This program is distributed in the hope that it will be useful, |
83 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
84 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
85 | +# GNU Affero General Public License for more details. |
86 | +# |
87 | +# You should have received a copy of the GNU Affero General Public License |
88 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
89 | +# |
90 | +############################################################################## |
91 | + |
92 | +from . import statement |
93 | + |
94 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
95 | |
96 | === added file 'account_statement_regex_account_completion/__openerp__.py' |
97 | --- account_statement_regex_account_completion/__openerp__.py 1970-01-01 00:00:00 +0000 |
98 | +++ account_statement_regex_account_completion/__openerp__.py 2014-01-22 11:18:45 +0000 |
99 | @@ -0,0 +1,56 @@ |
100 | +# -*- coding: utf-8 -*- |
101 | +############################################################################## |
102 | +# |
103 | +# Authors: Laetitia Gangloff |
104 | +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
105 | +# All Rights Reserved |
106 | +# |
107 | +# WARNING: This program as such is intended to be used by professional |
108 | +# programmers who take the whole responsibility of assessing all potential |
109 | +# consequences resulting from its eventual inadequacies and bugs. |
110 | +# End users who are looking for a ready-to-use solution with commercial |
111 | +# guarantees and support are strongly advised to contact a Free Software |
112 | +# Service Company. |
113 | +# |
114 | +# This program is free software: you can redistribute it and/or modify |
115 | +# it under the terms of the GNU Affero General Public License as |
116 | +# published by the Free Software Foundation, either version 3 of the |
117 | +# License, or (at your option) any later version. |
118 | +# |
119 | +# This program is distributed in the hope that it will be useful, |
120 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
121 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
122 | +# GNU Affero General Public License for more details. |
123 | +# |
124 | +# You should have received a copy of the GNU Affero General Public License |
125 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
126 | +# |
127 | +############################################################################## |
128 | + |
129 | +{ |
130 | + "name": "Account Statement Regex Account Completion addon", |
131 | + "version": "0.1", |
132 | + "author": "ACSONE SA/NV", |
133 | + "category": "Other", |
134 | + "website": "http://www.acsone.eu", |
135 | + "depends": ["account_statement_base_completion", |
136 | + ], |
137 | + "description": """ |
138 | + |
139 | +Account Statement Regex Account Completion addon |
140 | +========================= |
141 | + |
142 | +- Add a completion method based on a specified regular expression |
143 | + and update account to use in the bank statement line with the specified account. |
144 | +""", |
145 | + "data": ['statement_view.xml', |
146 | + ], |
147 | + "demo": [], |
148 | + "test": [], |
149 | + "active": False, |
150 | + "license": "AGPL-3", |
151 | + "installable": True, |
152 | + "auto_install": False, |
153 | + "application": False, |
154 | +} |
155 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
156 | |
157 | === added directory 'account_statement_regex_account_completion/i18n' |
158 | === added file 'account_statement_regex_account_completion/i18n/account_statement_regex_account_completion.pot' |
159 | --- account_statement_regex_account_completion/i18n/account_statement_regex_account_completion.pot 1970-01-01 00:00:00 +0000 |
160 | +++ account_statement_regex_account_completion/i18n/account_statement_regex_account_completion.pot 2014-01-22 11:18:45 +0000 |
161 | @@ -0,0 +1,32 @@ |
162 | +# Translation of OpenERP Server. |
163 | +# This file contains the translation of the following modules: |
164 | +# * account_statement_regex_account_completion |
165 | +# |
166 | +msgid "" |
167 | +msgstr "" |
168 | +"Project-Id-Version: OpenERP Server 7.0\n" |
169 | +"Report-Msgid-Bugs-To: \n" |
170 | +"POT-Creation-Date: 2014-01-22 10:59+0000\n" |
171 | +"PO-Revision-Date: 2014-01-22 10:59+0000\n" |
172 | +"Last-Translator: <>\n" |
173 | +"Language-Team: \n" |
174 | +"MIME-Version: 1.0\n" |
175 | +"Content-Type: text/plain; charset=UTF-8\n" |
176 | +"Content-Transfer-Encoding: \n" |
177 | +"Plural-Forms: \n" |
178 | + |
179 | +#. module: account_statement_regex_account_completion |
180 | +#: field:account.statement.completion.rule,regex:0 |
181 | +msgid "Regular Expression" |
182 | +msgstr "" |
183 | + |
184 | +#. module: account_statement_regex_account_completion |
185 | +#: field:account.statement.completion.rule,account_id:0 |
186 | +msgid "Account to set" |
187 | +msgstr "" |
188 | + |
189 | +#. module: account_statement_regex_account_completion |
190 | +#: model:ir.model,name:account_statement_regex_account_completion.model_account_statement_completion_rule |
191 | +msgid "account.statement.completion.rule" |
192 | +msgstr "" |
193 | + |
194 | |
195 | === added file 'account_statement_regex_account_completion/i18n/fr.po' |
196 | --- account_statement_regex_account_completion/i18n/fr.po 1970-01-01 00:00:00 +0000 |
197 | +++ account_statement_regex_account_completion/i18n/fr.po 2014-01-22 11:18:45 +0000 |
198 | @@ -0,0 +1,32 @@ |
199 | +# Translation of OpenERP Server. |
200 | +# This file contains the translation of the following modules: |
201 | +# * account_statement_regex_account_completion |
202 | +# |
203 | +msgid "" |
204 | +msgstr "" |
205 | +"Project-Id-Version: OpenERP Server 7.0\n" |
206 | +"Report-Msgid-Bugs-To: \n" |
207 | +"POT-Creation-Date: 2014-01-22 10:59+0000\n" |
208 | +"PO-Revision-Date: 2014-01-22 10:59+0000\n" |
209 | +"Last-Translator: <>\n" |
210 | +"Language-Team: \n" |
211 | +"MIME-Version: 1.0\n" |
212 | +"Content-Type: text/plain; charset=UTF-8\n" |
213 | +"Content-Transfer-Encoding: \n" |
214 | +"Plural-Forms: \n" |
215 | + |
216 | +#. module: account_statement_regex_account_completion |
217 | +#: field:account.statement.completion.rule,regex:0 |
218 | +msgid "Regular Expression" |
219 | +msgstr "Expression Régulière" |
220 | + |
221 | +#. module: account_statement_regex_account_completion |
222 | +#: field:account.statement.completion.rule,account_id:0 |
223 | +msgid "Account to set" |
224 | +msgstr "Compte à utiliser" |
225 | + |
226 | +#. module: account_statement_regex_account_completion |
227 | +#: model:ir.model,name:account_statement_regex_account_completion.model_account_statement_completion_rule |
228 | +msgid "account.statement.completion.rule" |
229 | +msgstr "account.statement.completion.rule" |
230 | + |
231 | \ No newline at end of file |
232 | |
233 | === added file 'account_statement_regex_account_completion/statement.py' |
234 | --- account_statement_regex_account_completion/statement.py 1970-01-01 00:00:00 +0000 |
235 | +++ account_statement_regex_account_completion/statement.py 2014-01-22 11:18:45 +0000 |
236 | @@ -0,0 +1,75 @@ |
237 | +# -*- coding: utf-8 -*- |
238 | +############################################################################## |
239 | +# |
240 | +# Authors: Laetitia Gangloff |
241 | +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
242 | +# All Rights Reserved |
243 | +# |
244 | +# WARNING: This program as such is intended to be used by professional |
245 | +# programmers who take the whole responsibility of assessing all potential |
246 | +# consequences resulting from its eventual inadequacies and bugs. |
247 | +# End users who are looking for a ready-to-use solution with commercial |
248 | +# guarantees and support are strongly advised to contact a Free Software |
249 | +# Service Company. |
250 | +# |
251 | +# This program is free software: you can redistribute it and/or modify |
252 | +# it under the terms of the GNU Affero General Public License as |
253 | +# published by the Free Software Foundation, either version 3 of the |
254 | +# License, or (at your option) any later version. |
255 | +# |
256 | +# This program is distributed in the hope that it will be useful, |
257 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
258 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
259 | +# GNU Affero General Public License for more details. |
260 | +# |
261 | +# You should have received a copy of the GNU Affero General Public License |
262 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
263 | +# |
264 | +############################################################################## |
265 | + |
266 | + |
267 | +from openerp.osv.orm import Model |
268 | +from openerp.osv import fields |
269 | + |
270 | +import re |
271 | + |
272 | + |
273 | +class AccountStatementCompletionRule(Model): |
274 | + """Add a rule to complete account based on a regular expression""" |
275 | + |
276 | + _inherit = "account.statement.completion.rule" |
277 | + |
278 | + def _get_functions(self, cr, uid, context=None): |
279 | + res = super(AccountStatementCompletionRule, self)._get_functions( |
280 | + cr, uid, context=context) |
281 | + res.append(('set_account', |
282 | + 'Set account for line labels matching a regular expression')) |
283 | + return res |
284 | + |
285 | + _columns = { |
286 | + 'function_to_call': fields.selection(_get_functions, 'Method'), |
287 | + 'regex': fields.char('Regular Expression', size=128), |
288 | + 'account_id': fields.many2one('account.account', string="Account to set"), |
289 | + } |
290 | + |
291 | + def set_account(self, cr, uid, id, st_line, context=None): |
292 | + """ |
293 | + If line name match regex, update account_id |
294 | + Then, call the generic st_line method to complete other values. |
295 | + :param dict st_line: read of the concerned account.bank.statement.line |
296 | + :return: |
297 | + A dict of value that can be passed directly to the write method of |
298 | + the statement line or {} |
299 | + {'partner_id': value, |
300 | + 'account_id' : value, |
301 | + ...} |
302 | + """ |
303 | + name = st_line['name'] |
304 | + res = {} |
305 | + if name: |
306 | + rule = self.browse(cr, uid, id, context=context) |
307 | + if re.match(rule.regex, name): |
308 | + res['account_id'] = rule.account_id.id |
309 | + return res |
310 | + |
311 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
312 | |
313 | === added file 'account_statement_regex_account_completion/statement_view.xml' |
314 | --- account_statement_regex_account_completion/statement_view.xml 1970-01-01 00:00:00 +0000 |
315 | +++ account_statement_regex_account_completion/statement_view.xml 2014-01-22 11:18:45 +0000 |
316 | @@ -0,0 +1,21 @@ |
317 | +<?xml version="1.0" encoding="utf-8"?> |
318 | +<openerp> |
319 | +<data> |
320 | + |
321 | + <record id="statement_st_completion_rule_view_form" model="ir.ui.view"> |
322 | + <field name="name">account.statement.completion.rule.view (account_statement_regex_account_completion)</field> |
323 | + <field name="model">account.statement.completion.rule</field> |
324 | + <field name="inherit_id" ref="account_statement_base_completion.statement_st_completion_rule_view_form" /> |
325 | + <field name="type">form</field> |
326 | + <field name="arch" type="xml"> |
327 | + <field name="function_to_call" position="after"> |
328 | + <group colspan="2"> |
329 | + <field name="regex" attrs="{'invisible':[('function_to_call','!=','set_account')],'required':[('function_to_call','=','set_account')]}"/> |
330 | + <field name="account_id" attrs="{'invisible':[('function_to_call','!=','set_account')],'required':[('function_to_call','=','set_account')]}"/> |
331 | + </group> |
332 | + </field> |
333 | + </field> |
334 | + </record> |
335 | + |
336 | +</data> |
337 | +</openerp> |
338 | |
339 | === added directory 'account_statement_regex_account_completion/tests' |
340 | === added file 'account_statement_regex_account_completion/tests/__init__.py' |
341 | --- account_statement_regex_account_completion/tests/__init__.py 1970-01-01 00:00:00 +0000 |
342 | +++ account_statement_regex_account_completion/tests/__init__.py 2014-01-22 11:18:45 +0000 |
343 | @@ -0,0 +1,36 @@ |
344 | +# -*- coding: utf-8 -*- |
345 | +############################################################################## |
346 | +# |
347 | +# Authors: Laetitia Gangloff |
348 | +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
349 | +# All Rights Reserved |
350 | +# |
351 | +# WARNING: This program as such is intended to be used by professional |
352 | +# programmers who take the whole responsibility of assessing all potential |
353 | +# consequences resulting from its eventual inadequacies and bugs. |
354 | +# End users who are looking for a ready-to-use solution with commercial |
355 | +# guarantees and support are strongly advised to contact a Free Software |
356 | +# Service Company. |
357 | +# |
358 | +# This program is free software: you can redistribute it and/or modify |
359 | +# it under the terms of the GNU Affero General Public License as |
360 | +# published by the Free Software Foundation, either version 3 of the |
361 | +# License, or (at your option) any later version. |
362 | +# |
363 | +# This program is distributed in the hope that it will be useful, |
364 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
365 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
366 | +# GNU Affero General Public License for more details. |
367 | +# |
368 | +# You should have received a copy of the GNU Affero General Public License |
369 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
370 | +# |
371 | +############################################################################## |
372 | + |
373 | +from . import test_regex_account_completion |
374 | + |
375 | +checks = [ |
376 | + test_regex_account_completion |
377 | +] |
378 | + |
379 | +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
380 | |
381 | === added file 'account_statement_regex_account_completion/tests/test_regex_account_completion.py' |
382 | --- account_statement_regex_account_completion/tests/test_regex_account_completion.py 1970-01-01 00:00:00 +0000 |
383 | +++ account_statement_regex_account_completion/tests/test_regex_account_completion.py 2014-01-22 11:18:45 +0000 |
384 | @@ -0,0 +1,91 @@ |
385 | +# -*- coding: utf-8 -*- |
386 | +############################################################################## |
387 | +# |
388 | +# Authors: Laetitia Gangloff |
389 | +# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu) |
390 | +# All Rights Reserved |
391 | +# |
392 | +# WARNING: This program as such is intended to be used by professional |
393 | +# programmers who take the whole responsibility of assessing all potential |
394 | +# consequences resulting from its eventual inadequacies and bugs. |
395 | +# End users who are looking for a ready-to-use solution with commercial |
396 | +# guarantees and support are strongly advised to contact a Free Software |
397 | +# Service Company. |
398 | +# |
399 | +# This program is free software: you can redistribute it and/or modify |
400 | +# it under the terms of the GNU Affero General Public License as |
401 | +# published by the Free Software Foundation, either version 3 of the |
402 | +# License, or (at your option) any later version. |
403 | +# |
404 | +# This program is distributed in the hope that it will be useful, |
405 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
406 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
407 | +# GNU Affero General Public License for more details. |
408 | +# |
409 | +# You should have received a copy of the GNU Affero General Public License |
410 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
411 | +# |
412 | +############################################################################## |
413 | + |
414 | +from openerp.tests import common |
415 | +import time |
416 | + |
417 | +ACC_NUMBER = "BE38733040385372" |
418 | + |
419 | + |
420 | +class test_regex_account_completion(common.TransactionCase): |
421 | + |
422 | + def prepare(self): |
423 | + self.account_bank_statement_obj = self.registry("account.bank.statement") |
424 | + self.account_bank_statement_line_obj = self.registry("account.bank.statement.line") |
425 | + self.account_id = self.ref('account.a_expense') |
426 | + # create the completion rule |
427 | + rule_vals = {'function_to_call': 'set_account', |
428 | + 'regex': '^My statement', |
429 | + 'account_id': self.account_id} |
430 | + completion_rule_id = self.registry("account.statement.completion.rule").create(self.cr, self.uid, rule_vals) |
431 | + |
432 | + # Create the profile |
433 | + journal_id = self.ref("account.bank_journal") |
434 | + profile_id = self.registry("account.statement.profile").create(self.cr, self.uid, { |
435 | + "name": "TEST", |
436 | + "commission_account_id": self.ref("account.a_recv"), |
437 | + "journal_id": journal_id, |
438 | + "rule_ids": [(6, 0, [completion_rule_id])]}) |
439 | + |
440 | + # Create a bank statement |
441 | + self.statement_id = self.account_bank_statement_obj.create(self.cr, self.uid, { |
442 | + "balance_end_real": 0.0, |
443 | + "balance_start": 0.0, |
444 | + "date": time.strftime('%Y-%m-%d'), |
445 | + "journal_id": journal_id, |
446 | + "profile_id": profile_id |
447 | + }) |
448 | + |
449 | + # Create two bank statement lines |
450 | + self.statement_line1_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { |
451 | + 'amount': 1000.0, |
452 | + 'name': 'My statement', |
453 | + 'ref': 'My ref', |
454 | + 'statement_id': self.statement_id, |
455 | + 'partner_acc_number': ACC_NUMBER |
456 | + }) |
457 | + |
458 | + self.statement_line2_id = self.account_bank_statement_line_obj.create(self.cr, self.uid, { |
459 | + 'amount': 2000.0, |
460 | + 'name': 'My second statement', |
461 | + 'ref': 'My second ref', |
462 | + 'statement_id': self.statement_id, |
463 | + 'partner_acc_number': ACC_NUMBER |
464 | + }) |
465 | + |
466 | + def test_00(self): |
467 | + """Test the automatic completion on account |
468 | + """ |
469 | + self.prepare() |
470 | + statement_obj = self.account_bank_statement_obj.browse(self.cr, self.uid, self.statement_id) |
471 | + statement_obj.button_auto_completion() |
472 | + statement_line1 = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line1_id) |
473 | + self.assertEquals(self.account_id, statement_line1.account_id.id, "The account should be the account of the completion") |
474 | + statement_line2 = self.account_bank_statement_line_obj.browse(self.cr, self.uid, self.statement_line2_id) |
475 | + self.assertNotEqual(self.account_id, statement_line2.account_id.id, "The account should be not the account of the completion") |
With your changes, the 'AccountStateme ntProfil. _get_callable' function no more return a list of callable but a sorted list of browser_record of account. statement. completion. rule. _get_rule_ids could be a better name?
At line 29, len(inspect. getargspec( method_ to_call) ) will always return 5.