Analytic account lines not being created for account moves
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) | Status tracked in Trunk | |||||
5.0 |
Fix Released
|
High
|
Vinay Rana (OpenERP) | |||
Trunk |
Fix Released
|
High
|
Vinay Rana (OpenERP) |
Bug Description
The account move validation (validate method of the account.move object) is broken on both 5.0 and 6.0 (worse in the latter one), preventing the creation of analytic account lines (on some cases in 5.0, every case on 6.0).
--- On 5.0 -------
On 5.0 we have some code like this:
def validate(self, cr, uid, ids, context={}):
...
ok = True
for move in self.browse(cr, uid, ids, context):
...
if ok:
for tmp in move.line_id:
As you can see, that "if ok" conditional branch is invalid:
1 - Is only executed once! not for each move.
2 - The "move" variable, may be undefined (it's defined on the loop); but being lucky (suppose that ids is never empty) it will be just the last move of the collection. Only the last move (if "ids" contains more than one move) gets it's analytic lines created.
So, it works just out of luck!
--- On 6.0 -------
P. Christeas saw this bug when working on the 6.0, and tried to fix it (on 2009-01-22, revno 1628.3.67, revid <email address hidden>: "Fix apparent indentation error until the world collapses." http://
With that fix, the 6.0 will no longer create analytic lines!
Why? Cause it never reaches that code!
If you take a deeper look at the validated method, you can see that each conditional branch skipes the end of the loop (either by doing a 'continue', or by doing a 'ok=False'), so yes, create_
def validate(self, cr, uid, ids, context={}):
...
ok = True
for move in self.browse(cr, uid, ids, context):
...
for line in move.line_id:
...
if abs(amount) < 0.0001:
...
if journal.
...
else:
...
ok = False
if ok:
for tmp in move.line_id:
return ok
Conclusion: the account.move validate method code is severely broken and must be fixed (on 5.0) / refactored (on 6.0) ASAP!
Changed in openobject-addons: | |
assignee: | nobody → vra (openerp) (vra-openerp) |
status: | Confirmed → In Progress |
Changed in openobject-addons: | |
milestone: | 5.0.12 → 6.0 |
summary: |
- [6.0/5.0] Analytic account lines not being created for account moves + [6.0] Analytic account lines not being created for account moves |
Added patch for the trunk version, that fixes the validate method and makes the code cleaner (no continues but branches, more comments...)