Merge lp:~pedro.baeza/ocb-addons/6.1-fix-1223243 into lp:ocb-addons/6.1

Proposed by Pedro Manuel Baeza
Status: Work in progress
Proposed branch: lp:~pedro.baeza/ocb-addons/6.1-fix-1223243
Merge into: lp:ocb-addons/6.1
Diff against target: 75 lines (+8/-22)
2 files modified
account/account.py (+5/-7)
account/account_move_line.py (+3/-15)
To merge this branch: bzr merge lp:~pedro.baeza/ocb-addons/6.1-fix-1223243
Reviewer Review Type Date Requested Status
Stefan Rijnhart (Opener) Needs Fixing
Review via email: mp+198291@code.launchpad.net

Description of the change

Improvement made on 7.0 when posting account move lines. I have to admit that I haven't fully tested it, but overall checks are OK and the improvement deserves to make the MP.

Regards.

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

It is a cherrypicking from revisions 9458 and 9679 of 7.0 branch, manually merging conflicting lines.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Pedro,

I know you do a lot of good work, but I am a little unhappy with a proposal that you did not even fully test yourself (thank you for your honesty though!). That's enough to warrant a disapproval as far as I'm concerned, as you can't really expect a reviewer to spend valuable time on that.

Also, I am having a hard time trying to find out what this change really does. There is no bug report, and it even looks like there are several changes. In that case, you really should put in a detailed description of what each change does, if only to convince the reviewers that these changes are a good thing. And if upstream revision numbers are the only pointers, at least make them links to the revisions on Launchpad!

review: Needs Fixing
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Stefan, thanks for your prudence, and sorry for the mistakes on this MP. First of all, I thought that I linked the corresponding bug, but I wasn't. Now, it is linked. In this bug are explained all the changes, but I paste here again for reference:

- revision 9458: reduce the number of time validate() function is called on account move (worst case was one per line, now should be one per move)
- revision 9679: reduce the number of time analytic lines are created and dropped as mentioned Frederic (only end of validation, unbalanced move creates no analytic lines)

I'm going to set this as WIP until I have some time to fully tested.

Regards.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for clarifying!

Unmerged revisions

6822. By Pedro Manuel Baeza

[IMP] Backport of 7.0 rev. 9458 and 9679

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2013-11-20 01:17:39 +0000
3+++ account/account.py 2013-12-09 17:06:05 +0000
4@@ -1422,11 +1422,14 @@
5 l[2]['period_id'] = default_period
6 context['period_id'] = default_period
7
8- if 'line_id' in vals:
9+ if vals.get('line_id', False):
10 c = context.copy()
11 c['novalidate'] = True
12 result = super(account_move, self).create(cr, uid, vals, c)
13- self.validate(cr, uid, [result], context)
14+ tmp = self.validate(cr, uid, [result], context)
15+ journal = self.pool.get('account.journal').browse(cr, uid, vals['journal_id'], context)
16+ if journal.entry_posted and tmp:
17+ self.button_validate(cr,uid, [result], context)
18 else:
19 result = super(account_move, self).create(cr, uid, vals, context)
20 return result
21@@ -1569,11 +1572,6 @@
22 obj_analytic_line = self.pool.get('account.analytic.line')
23 obj_move_line = self.pool.get('account.move.line')
24 for move in self.browse(cr, uid, ids, context):
25- # Unlink old analytic lines on move_lines
26- for obj_line in move.line_id:
27- for obj in obj_line.analytic_lines:
28- obj_analytic_line.unlink(cr,uid,obj.id)
29-
30 journal = move.journal_id
31 amount = 0
32 line_ids = []
33
34=== modified file 'account/account_move_line.py'
35--- account/account_move_line.py 2012-09-06 14:35:17 +0000
36+++ account/account_move_line.py 2013-12-09 17:06:05 +0000
37@@ -171,6 +171,8 @@
38 if obj_line.analytic_account_id:
39 if not obj_line.journal_id.analytic_journal_id:
40 raise osv.except_osv(_('No Analytic Journal !'),_("You have to define an analytic journal on the '%s' journal!") % (obj_line.journal_id.name, ))
41+ if obj_line.analytic_lines:
42+ acc_ana_line_obj.unlink(cr,uid,[obj.id for obj in obj_line.analytic_lines])
43 amt = (obj_line.credit or 0.0) - (obj_line.debit or 0.0)
44 vals_lines = {
45 'name': obj_line.name,
46@@ -1316,20 +1318,6 @@
47 if not ok:
48 raise osv.except_osv(_('Bad account !'), _('You can not use this general account in this journal, check the tab \'Entry Controls\' on the related journal !'))
49
50- if vals.get('analytic_account_id',False):
51- if journal.analytic_journal_id:
52- vals['analytic_lines'] = [(0,0, {
53- 'name': vals['name'],
54- 'date': vals.get('date', time.strftime('%Y-%m-%d')),
55- 'account_id': vals.get('analytic_account_id', False),
56- 'unit_amount': vals.get('quantity', 1.0),
57- 'amount': vals.get('debit', 0.0) or vals.get('credit', 0.0),
58- 'general_account_id': vals.get('account_id', False),
59- 'journal_id': journal.analytic_journal_id.id,
60- 'ref': vals.get('ref', False),
61- 'user_id': uid
62- })]
63-
64 result = super(account_move_line, self).create(cr, uid, vals, context=context)
65 # CREATE Taxes
66 if vals.get('account_tax_id', False):
67@@ -1391,7 +1379,7 @@
68 self.create(cr, uid, data, context)
69 del vals['account_tax_id']
70
71- if check and ((not context.get('no_store_function')) or journal.entry_posted):
72+ if check and not context.get('novalidate') and ((not context.get('no_store_function')) or journal.entry_posted):
73 tmp = move_obj.validate(cr, uid, [vals['move_id']], context)
74 if journal.entry_posted and tmp:
75 move_obj.button_validate(cr,uid, [vals['move_id']], context)

Subscribers

People subscribed via source and target branches