Merge lp:~acsone-openerp/account-analytic/account_analytic_required-test_suite-sbi into lp:~account-core-editors/account-analytic/7.0
- account_analytic_required-test_suite-sbi
- Merge into 7.0
Proposed by
Stéphane Bidoul (Acsone)
Status: | Merged |
---|---|
Merged at revision: | 18 |
Proposed branch: | lp:~acsone-openerp/account-analytic/account_analytic_required-test_suite-sbi |
Merge into: | lp:~account-core-editors/account-analytic/7.0 |
Diff against target: |
369 lines (+249/-31) 6 files modified
account_analytic_required/__init__.py (+1/-1) account_analytic_required/__openerp__.py (+17/-9) account_analytic_required/account.py (+59/-20) account_analytic_required/account_view.xml (+12/-1) account_analytic_required/tests/__init__.py (+30/-0) account_analytic_required/tests/test_account_analytic_required.py (+130/-0) |
To merge this branch: | bzr merge lp:~acsone-openerp/account-analytic/account_analytic_required-test_suite-sbi |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Approve | ||
Alexis de Lattre (community) | code review and tests | Approve | |
Pedro Manuel Baeza | code review | Approve | |
Review via email: mp+216451@code.launchpad.net |
Commit message
Description of the change
Add a test suite for account_
To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
review:
Approve
(code review)
Revision history for this message
Alexis de Lattre (alexis-via) wrote : | # |
Nice update. Thank you Stefan.
I am pushing to you a branch with pep8 stuff and the additional of the field in the tree view (and not just form view).
review:
Approve
(code review and tests)
Revision history for this message
Alexis de Lattre (alexis-via) wrote : | # |
- 19. By Stéphane Bidoul (Acsone)
-
[MRG] flake8 long lines + add policy in tree view from Alexis de Lattre
- 20. By Stéphane Bidoul (Acsone)
-
[IMP] comments in test suite + long lines __openerp__.py
Revision history for this message
Alexis de Lattre (alexis-via) wrote : | # |
OK, let's go and merge it in the main branch now :)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'account_analytic_required/__init__.py' | |||
2 | --- account_analytic_required/__init__.py 2012-11-21 08:56:48 +0000 | |||
3 | +++ account_analytic_required/__init__.py 2014-04-19 10:20:35 +0000 | |||
4 | @@ -21,4 +21,4 @@ | |||
5 | 21 | ############################################################################## | 21 | ############################################################################## |
6 | 22 | 22 | ||
7 | 23 | 23 | ||
9 | 24 | import account | 24 | from . import account |
10 | 25 | 25 | ||
11 | === modified file 'account_analytic_required/__openerp__.py' | |||
12 | --- account_analytic_required/__openerp__.py 2013-04-23 14:25:48 +0000 | |||
13 | +++ account_analytic_required/__openerp__.py 2014-04-19 10:20:35 +0000 | |||
14 | @@ -2,7 +2,7 @@ | |||
15 | 2 | ############################################################################## | 2 | ############################################################################## |
16 | 3 | # | 3 | # |
17 | 4 | # Account analytic required module for OpenERP | 4 | # Account analytic required module for OpenERP |
19 | 5 | # Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved | 5 | # Copyright (C) 2011 Akretion (http://www.akretion.com) |
20 | 6 | # @author Alexis de Lattre <alexis.delattre@akretion.com> | 6 | # @author Alexis de Lattre <alexis.delattre@akretion.com> |
21 | 7 | # | 7 | # |
22 | 8 | # This program is free software: you can redistribute it and/or modify | 8 | # This program is free software: you can redistribute it and/or modify |
23 | @@ -22,15 +22,24 @@ | |||
24 | 22 | 22 | ||
25 | 23 | 23 | ||
26 | 24 | { | 24 | { |
28 | 25 | 'name': 'Account analytic required', | 25 | 'name': 'Account Analytic Required', |
29 | 26 | 'version': '0.2', | 26 | 'version': '0.2', |
31 | 27 | 'category': 'Generic Modules/Accounting', | 27 | 'category': 'Analytic Accounting', |
32 | 28 | 'license': 'AGPL-3', | 28 | 'license': 'AGPL-3', |
38 | 29 | 'description': """This module adds an option "analytic policy" on account types. You have the choice between 3 policies : always, never and optional. | 29 | 'description': """ |
39 | 30 | 30 | Account Analytic Required | |
40 | 31 | For example, if you want to have an analytic account on all your expenses, set the policy to "always" for the account type "expense" ; then, if you try to save an account move line with an account of type "expense" without analytic account, you will get an error message. | 31 | ========================= |
41 | 32 | 32 | ||
42 | 33 | Module developped by Alexis de Lattre <alexis.delattre@akretion.com> during the Akretion-Camptocamp code sprint of June 2011. | 33 | This module adds an option *analytic policy* on account types. |
43 | 34 | You have the choice between 3 policies : *always*, *never* and *optional*. | ||
44 | 35 | |||
45 | 36 | For example, if you want to have an analytic account on all your expenses, | ||
46 | 37 | set the policy to *always* for the account type *expense* ; then, if you | ||
47 | 38 | try to save an account move line with an account of type *expense* | ||
48 | 39 | without analytic account, you will get an error message. | ||
49 | 40 | |||
50 | 41 | Module developped by Alexis de Lattre <alexis.delattre@akretion.com> | ||
51 | 42 | during the Akretion-Camptocamp code sprint of June 2011. | ||
52 | 34 | """, | 43 | """, |
53 | 35 | 'author': 'Akretion', | 44 | 'author': 'Akretion', |
54 | 36 | 'website': 'http://www.akretion.com/', | 45 | 'website': 'http://www.akretion.com/', |
55 | @@ -39,4 +48,3 @@ | |||
56 | 39 | 'installable': True, | 48 | 'installable': True, |
57 | 40 | 'active': False, | 49 | 'active': False, |
58 | 41 | } | 50 | } |
59 | 42 | |||
60 | 43 | 51 | ||
61 | === modified file 'account_analytic_required/account.py' | |||
62 | --- account_analytic_required/account.py 2013-04-23 14:25:48 +0000 | |||
63 | +++ account_analytic_required/account.py 2014-04-19 10:20:35 +0000 | |||
64 | @@ -2,7 +2,7 @@ | |||
65 | 2 | ############################################################################## | 2 | ############################################################################## |
66 | 3 | # | 3 | # |
67 | 4 | # Account analytic required module for OpenERP | 4 | # Account analytic required module for OpenERP |
69 | 5 | # Copyright (C) 2011 Akretion (http://www.akretion.com). All Rights Reserved | 5 | # Copyright (C) 2011 Akretion (http://www.akretion.com) |
70 | 6 | # @author Alexis de Lattre <alexis.delattre@akretion.com> | 6 | # @author Alexis de Lattre <alexis.delattre@akretion.com> |
71 | 7 | # Developped during the Akretion-Camptocamp code sprint of June 2011 | 7 | # Developped during the Akretion-Camptocamp code sprint of June 2011 |
72 | 8 | # | 8 | # |
73 | @@ -22,43 +22,82 @@ | |||
74 | 22 | ############################################################################## | 22 | ############################################################################## |
75 | 23 | 23 | ||
76 | 24 | from openerp.osv import orm, fields | 24 | from openerp.osv import orm, fields |
78 | 25 | from tools.translate import _ | 25 | from openerp.tools.translate import _ |
79 | 26 | 26 | ||
80 | 27 | 27 | ||
81 | 28 | class account_account_type(orm.Model): | 28 | class account_account_type(orm.Model): |
82 | 29 | _inherit = "account.account.type" | 29 | _inherit = "account.account.type" |
83 | 30 | 30 | ||
84 | 31 | _columns = { | 31 | _columns = { |
86 | 32 | 'analytic_policy' : fields.selection([ | 32 | 'analytic_policy': fields.selection([ |
87 | 33 | ('optional', 'Optional'), | 33 | ('optional', 'Optional'), |
88 | 34 | ('always', 'Always'), | 34 | ('always', 'Always'), |
89 | 35 | ('never', 'Never') | 35 | ('never', 'Never') |
91 | 36 | ], 'Policy for analytic account', help="Set the policy for analytic accounts : if you select 'Optional', the accountant is free to put an analytic account on an account move line with this type of account ; if you select 'Always', the accountant will get an error message if there is no analytic account ; if you select 'Never', the accountant will get an error message if an analytic account is present."), | 36 | ], 'Policy for analytic account', |
92 | 37 | help="Set the policy for analytic accounts : if you select " | ||
93 | 38 | "'Optional', the accountant is free to put an analytic account " | ||
94 | 39 | "on an account move line with this type of account ; if you " | ||
95 | 40 | "select 'Always', the accountant will get an error message if " | ||
96 | 41 | "there is no analytic account ; if you select 'Never', the " | ||
97 | 42 | "accountant will get an error message if an analytic account " | ||
98 | 43 | "is present."), | ||
99 | 37 | } | 44 | } |
100 | 38 | 45 | ||
101 | 39 | _defaults = { | 46 | _defaults = { |
103 | 40 | 'analytic_policy': lambda *a: 'optional', | 47 | 'analytic_policy': 'optional', |
104 | 41 | } | 48 | } |
105 | 42 | 49 | ||
106 | 43 | 50 | ||
107 | 44 | class account_move_line(orm.Model): | 51 | class account_move_line(orm.Model): |
108 | 45 | _inherit = "account.move.line" | 52 | _inherit = "account.move.line" |
109 | 46 | 53 | ||
118 | 47 | def check_analytic_required(self, cr, uid, vals, context=None): | 54 | def check_analytic_required(self, cr, uid, ids, vals, context=None): |
119 | 48 | if 'account_id' in vals and (vals.get('debit', 0.0) != 0.0 or vals.get('credit', 0.0) != 0.0): | 55 | if 'account_id' in vals or 'analytic_account_id' in vals or \ |
120 | 49 | account = self.pool.get('account.account').browse(cr, uid, vals['account_id'], context=context) | 56 | 'debit' in vals or 'credit' in vals: |
121 | 50 | if account.user_type.analytic_policy == 'always' and not vals.get('analytic_account_id', False): | 57 | if isinstance(ids, (int, long)): |
122 | 51 | raise orm.except_orm(_('Error :'), _("Analytic policy is set to 'Always' with account %s '%s' but the analytic account is missing in the account move line with label '%s'." % (account.code, account.name, vals.get('name', False)))) | 58 | ids = [ids] |
123 | 52 | elif account.user_type.analytic_policy == 'never' and vals.get('analytic_account_id', False): | 59 | for move_line in self.browse(cr, uid, ids, context): |
124 | 53 | cur_analytic_account = self.pool.get('account.analytic.account').read(cr, uid, vals['analytic_account_id'], ['name', 'code'], context=context) | 60 | if move_line.debit == 0 and move_line.credit == 0: |
125 | 54 | raise orm.except_orm(_('Error :'), _("Analytic policy is set to 'Never' with account %s '%s' but the account move line with label '%s' has an analytic account %s '%s'." % (account.code, account.name, vals.get('name', False), cur_analytic_account['code'], cur_analytic_account['name']))) | 61 | continue |
126 | 62 | analytic_policy = \ | ||
127 | 63 | move_line.account_id.user_type.analytic_policy | ||
128 | 64 | if analytic_policy == 'always' and \ | ||
129 | 65 | not move_line.analytic_account_id: | ||
130 | 66 | raise orm.except_orm( | ||
131 | 67 | _('Error :'), | ||
132 | 68 | _("Analytic policy is set to 'Always' with account " | ||
133 | 69 | "%s '%s' but the analytic account is missing in " | ||
134 | 70 | "the account move line with label '%s'.") | ||
135 | 71 | % ( | ||
136 | 72 | move_line.account_id.code, | ||
137 | 73 | move_line.account_id.name, | ||
138 | 74 | move_line.name)) | ||
139 | 75 | elif analytic_policy == 'never' and \ | ||
140 | 76 | move_line.analytic_account_id: | ||
141 | 77 | raise orm.except_orm( | ||
142 | 78 | _('Error :'), | ||
143 | 79 | _("Analytic policy is set to 'Never' with account %s " | ||
144 | 80 | "'%s' but the account move line with label '%s' " | ||
145 | 81 | "has an analytic account %s '%s'.") | ||
146 | 82 | % ( | ||
147 | 83 | move_line.account_id.code, | ||
148 | 84 | move_line.account_id.name, | ||
149 | 85 | move_line.name, | ||
150 | 86 | move_line.analytic_account_id.code, | ||
151 | 87 | move_line.analytic_account_id.name)) | ||
152 | 55 | return True | 88 | return True |
153 | 56 | 89 | ||
154 | 57 | def create(self, cr, uid, vals, context=None, check=True): | 90 | def create(self, cr, uid, vals, context=None, check=True): |
162 | 58 | self.check_analytic_required(cr, uid, vals, context=context) | 91 | line_id = super(account_move_line, self).create( |
163 | 59 | return super(account_move_line, self).create(cr, uid, vals, context=context, check=check) | 92 | cr, uid, vals, context=context, check=check) |
164 | 60 | 93 | self.check_analytic_required(cr, uid, line_id, vals, context=context) | |
165 | 61 | def write(self, cr, uid, ids, vals, context=None, check=True, update_check=True): | 94 | return line_id |
166 | 62 | self.check_analytic_required(cr, uid, vals, context=context) | 95 | |
167 | 63 | return super(account_move_line, self).write(cr, uid, ids, vals, context=context, check=check, update_check=update_check) | 96 | def write( |
168 | 64 | 97 | self, cr, uid, ids, vals, context=None, check=True, | |
169 | 98 | update_check=True): | ||
170 | 99 | res = super(account_move_line, self).write( | ||
171 | 100 | cr, uid, ids, vals, context=context, check=check, | ||
172 | 101 | update_check=update_check) | ||
173 | 102 | self.check_analytic_required(cr, uid, ids, vals, context=context) | ||
174 | 103 | return res | ||
175 | 65 | 104 | ||
176 | === modified file 'account_analytic_required/account_view.xml' | |||
177 | --- account_analytic_required/account_view.xml 2012-11-21 08:56:48 +0000 | |||
178 | +++ account_analytic_required/account_view.xml 2014-04-19 10:20:35 +0000 | |||
179 | @@ -15,7 +15,18 @@ | |||
180 | 15 | <field name="inherit_id" ref="account.view_account_type_form" /> | 15 | <field name="inherit_id" ref="account.view_account_type_form" /> |
181 | 16 | <field name="arch" type="xml"> | 16 | <field name="arch" type="xml"> |
182 | 17 | <field name="code" position="after"> | 17 | <field name="code" position="after"> |
184 | 18 | <field name="analytic_policy" /> | 18 | <field name="analytic_policy" /> |
185 | 19 | </field> | ||
186 | 20 | </field> | ||
187 | 21 | </record> | ||
188 | 22 | |||
189 | 23 | <record id="view_account_type_tree" model="ir.ui.view"> | ||
190 | 24 | <field name="name">account_analytic_required.account_type_tree</field> | ||
191 | 25 | <field name="model">account.account.type</field> | ||
192 | 26 | <field name="inherit_id" ref="account.view_account_type_tree" /> | ||
193 | 27 | <field name="arch" type="xml"> | ||
194 | 28 | <field name="code" position="after"> | ||
195 | 29 | <field name="analytic_policy" /> | ||
196 | 19 | </field> | 30 | </field> |
197 | 20 | </field> | 31 | </field> |
198 | 21 | </record> | 32 | </record> |
199 | 22 | 33 | ||
200 | === added directory 'account_analytic_required/tests' | |||
201 | === added file 'account_analytic_required/tests/__init__.py' | |||
202 | --- account_analytic_required/tests/__init__.py 1970-01-01 00:00:00 +0000 | |||
203 | +++ account_analytic_required/tests/__init__.py 2014-04-19 10:20:35 +0000 | |||
204 | @@ -0,0 +1,30 @@ | |||
205 | 1 | # -*- encoding: utf-8 -*- | ||
206 | 2 | ############################################################################## | ||
207 | 3 | # | ||
208 | 4 | # Account analytic required module for OpenERP | ||
209 | 5 | # Copyright (C) 2014 Acsone (http://acsone.eu). All Rights Reserved | ||
210 | 6 | # @author Stéphane Bidoul <stephane.bidoul@acsone.eu> | ||
211 | 7 | # | ||
212 | 8 | # This program is free software: you can redistribute it and/or modify | ||
213 | 9 | # it under the terms of the GNU Affero General Public License as | ||
214 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
215 | 11 | # License, or (at your option) any later version. | ||
216 | 12 | # | ||
217 | 13 | # This program is distributed in the hope that it will be useful, | ||
218 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
219 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
220 | 16 | # GNU Affero General Public License for more details. | ||
221 | 17 | # | ||
222 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
223 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
224 | 20 | # | ||
225 | 21 | ############################################################################## | ||
226 | 22 | |||
227 | 23 | from . import test_account_analytic_required | ||
228 | 24 | |||
229 | 25 | fast_suite = [ | ||
230 | 26 | ] | ||
231 | 27 | |||
232 | 28 | checks = [ | ||
233 | 29 | test_account_analytic_required, | ||
234 | 30 | ] | ||
235 | 0 | 31 | ||
236 | === added file 'account_analytic_required/tests/test_account_analytic_required.py' | |||
237 | --- account_analytic_required/tests/test_account_analytic_required.py 1970-01-01 00:00:00 +0000 | |||
238 | +++ account_analytic_required/tests/test_account_analytic_required.py 2014-04-19 10:20:35 +0000 | |||
239 | @@ -0,0 +1,130 @@ | |||
240 | 1 | # -*- encoding: utf-8 -*- | ||
241 | 2 | ############################################################################## | ||
242 | 3 | # | ||
243 | 4 | # Account analytic required module for OpenERP | ||
244 | 5 | # Copyright (C) 2014 Acsone (http://acsone.eu). All Rights Reserved | ||
245 | 6 | # @author Stéphane Bidoul <stephane.bidoul@acsone.eu> | ||
246 | 7 | # | ||
247 | 8 | # This program is free software: you can redistribute it and/or modify | ||
248 | 9 | # it under the terms of the GNU Affero General Public License as | ||
249 | 10 | # published by the Free Software Foundation, either version 3 of the | ||
250 | 11 | # License, or (at your option) any later version. | ||
251 | 12 | # | ||
252 | 13 | # This program is distributed in the hope that it will be useful, | ||
253 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
254 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
255 | 16 | # GNU Affero General Public License for more details. | ||
256 | 17 | # | ||
257 | 18 | # You should have received a copy of the GNU Affero General Public License | ||
258 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
259 | 20 | # | ||
260 | 21 | ############################################################################## | ||
261 | 22 | |||
262 | 23 | from datetime import datetime | ||
263 | 24 | |||
264 | 25 | from openerp.tests import common | ||
265 | 26 | from openerp.osv import orm | ||
266 | 27 | |||
267 | 28 | |||
268 | 29 | class test_account_analytic_required(common.TransactionCase): | ||
269 | 30 | |||
270 | 31 | def setUp(self): | ||
271 | 32 | super(test_account_analytic_required, self).setUp() | ||
272 | 33 | self.account_obj = self.registry('account.account') | ||
273 | 34 | self.account_type_obj = self.registry('account.account.type') | ||
274 | 35 | self.move_obj = self.registry('account.move') | ||
275 | 36 | self.move_line_obj = self.registry('account.move.line') | ||
276 | 37 | self.analytic_account_obj = self.registry('account.analytic.account') | ||
277 | 38 | self.analytic_account_id = self.analytic_account_obj.create( | ||
278 | 39 | self.cr, self.uid, {'name': 'test aa', 'type': 'normal'}) | ||
279 | 40 | |||
280 | 41 | def _create_move(self, with_analytic, amount=100): | ||
281 | 42 | date = datetime.now() | ||
282 | 43 | period_id = self.registry('account.period').find( | ||
283 | 44 | self.cr, self.uid, date, | ||
284 | 45 | context={'account_period_prefer_normal': True})[0] | ||
285 | 46 | move_vals = { | ||
286 | 47 | 'journal_id': self.ref('account.sales_journal'), | ||
287 | 48 | 'period_id': period_id, | ||
288 | 49 | 'date': date, | ||
289 | 50 | } | ||
290 | 51 | move_id = self.move_obj.create(self.cr, self.uid, move_vals) | ||
291 | 52 | move_line_id = self.move_line_obj.create( | ||
292 | 53 | self.cr, self.uid, | ||
293 | 54 | {'move_id': move_id, | ||
294 | 55 | 'name': '/', | ||
295 | 56 | 'debit': 0, | ||
296 | 57 | 'credit': amount, | ||
297 | 58 | 'account_id': self.ref('account.a_sale'), | ||
298 | 59 | 'analytic_account_id': | ||
299 | 60 | self.analytic_account_id if with_analytic else False}) | ||
300 | 61 | self.move_line_obj.create( | ||
301 | 62 | self.cr, self.uid, | ||
302 | 63 | {'move_id': move_id, | ||
303 | 64 | 'name': '/', | ||
304 | 65 | 'debit': amount, | ||
305 | 66 | 'credit': 0, | ||
306 | 67 | 'account_id': self.ref('account.a_recv')}) | ||
307 | 68 | return move_line_id | ||
308 | 69 | |||
309 | 70 | def _set_analytic_policy(self, policy, aref='account.a_sale'): | ||
310 | 71 | account_type = self.account_obj.browse(self.cr, self.uid, | ||
311 | 72 | self.ref(aref)).user_type | ||
312 | 73 | self.account_type_obj.write(self.cr, self.uid, account_type.id, | ||
313 | 74 | {'analytic_policy': policy}) | ||
314 | 75 | |||
315 | 76 | def test_optional(self): | ||
316 | 77 | self._create_move(with_analytic=False) | ||
317 | 78 | self._create_move(with_analytic=True) | ||
318 | 79 | |||
319 | 80 | def test_always_no_analytic(self): | ||
320 | 81 | self._set_analytic_policy('always') | ||
321 | 82 | with self.assertRaises(orm.except_orm): | ||
322 | 83 | self._create_move(with_analytic=False) | ||
323 | 84 | |||
324 | 85 | def test_always_no_analytic_0(self): | ||
325 | 86 | # accept missing analytic account when debit=credit=0 | ||
326 | 87 | self._set_analytic_policy('always') | ||
327 | 88 | self._create_move(with_analytic=False, amount=0) | ||
328 | 89 | |||
329 | 90 | def test_always_with_analytic(self): | ||
330 | 91 | self._set_analytic_policy('always') | ||
331 | 92 | self._create_move(with_analytic=True) | ||
332 | 93 | |||
333 | 94 | def test_never_no_analytic(self): | ||
334 | 95 | self._set_analytic_policy('never') | ||
335 | 96 | self._create_move(with_analytic=False) | ||
336 | 97 | |||
337 | 98 | def test_never_with_analytic(self): | ||
338 | 99 | self._set_analytic_policy('never') | ||
339 | 100 | with self.assertRaises(orm.except_orm): | ||
340 | 101 | self._create_move(with_analytic=True) | ||
341 | 102 | |||
342 | 103 | def test_never_with_analytic_0(self): | ||
343 | 104 | # accept analytic when debit=credit=0 | ||
344 | 105 | self._set_analytic_policy('never') | ||
345 | 106 | self._create_move(with_analytic=True, amount=0) | ||
346 | 107 | |||
347 | 108 | def test_always_remove_analytic(self): | ||
348 | 109 | # remove partner when policy is always | ||
349 | 110 | self._set_analytic_policy('always') | ||
350 | 111 | line_id = self._create_move(with_analytic=True) | ||
351 | 112 | with self.assertRaises(orm.except_orm): | ||
352 | 113 | self.move_line_obj.write(self.cr, self.uid, line_id, | ||
353 | 114 | {'analytic_account_id': False}) | ||
354 | 115 | |||
355 | 116 | def test_change_account(self): | ||
356 | 117 | self._set_analytic_policy('always', aref='account.a_expense') | ||
357 | 118 | line_id = self._create_move(with_analytic=False) | ||
358 | 119 | # change account to a_expense with policy always but missing | ||
359 | 120 | # analytic_account | ||
360 | 121 | with self.assertRaises(orm.except_orm): | ||
361 | 122 | self.move_line_obj.write( | ||
362 | 123 | self.cr, self.uid, line_id, | ||
363 | 124 | {'account_id': self.ref('account.a_expense')}) | ||
364 | 125 | # change account to a_expense with policy always | ||
365 | 126 | # with analytic account -> ok | ||
366 | 127 | self.move_line_obj.write( | ||
367 | 128 | self.cr, self.uid, line_id, { | ||
368 | 129 | 'account_id': self.ref('account.a_expense'), | ||
369 | 130 | 'analytic_account_id': self.analytic_account_id}) |
Thanks for the work, Stéphane.
Regards.