Merge lp:~alhashash/openobject-addons/Fix_1087681_incorrect_move_line_defaults into lp:openobject-addons

Proposed by Mohammad Alhashash
Status: Needs review
Proposed branch: lp:~alhashash/openobject-addons/Fix_1087681_incorrect_move_line_defaults
Merge into: lp:openobject-addons
Diff against target: 25 lines (+9/-2)
1 file modified
account/account_move_line.py (+9/-2)
To merge this branch: bzr merge lp:~alhashash/openobject-addons/Fix_1087681_incorrect_move_line_defaults
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+138743@code.launchpad.net

Description of the change

in account.move_line._default_get(), do not use 'partner_id' or 'ref' from other lines as a default unless they are the same for all lines.

To post a comment you must log in.

Unmerged revisions

8236. By alhashash <alhashash@centos6-devel>

in account.move_line._default_get(), do not use 'partner_id' or 'ref' as a default from other line unless they are the same for all lines. Bug #1087681

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_move_line.py'
2--- account/account_move_line.py 2012-12-06 11:05:28 +0000
3+++ account/account_move_line.py 2012-12-07 14:49:23 +0000
4@@ -264,12 +264,19 @@
5 if move_id:
6 #if there exist some unbalanced accounting entries that match the journal and the period,
7 #we propose to continue the same move by copying the ref, the name, the partner...
8+ #ref and partners are copied only if all lines has the same ref or partner
9 move = move_obj.browse(cr, uid, move_id, context=context)
10 data.setdefault('name', move.line_id[-1].name)
11+ partner_set = set()
12+ ref_set = set()
13 for l in move.line_id:
14- data['partner_id'] = data.get('partner_id') or l.partner_id.id
15- data['ref'] = data.get('ref') or l.ref
16+ partner_set.add(l.partner_id.id)
17+ ref_set.add(l.ref)
18 total += (l.debit or 0.0) - (l.credit or 0.0)
19+ if len(partner_set) == 1: # same partner for all
20+ data['partner_id'] = data.get('partner_id') or partner_set.pop()
21+ if len(ref_set) == 1: # same ref for all
22+ data['ref'] = data.get('ref') or ref_set.pop()
23
24 #compute the total of current move
25 data['debit'] = total < 0 and -total or 0.0

Subscribers

People subscribed via source and target branches

to all changes: