Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-period-lep into lp:banking-addons/bank-statement-reconcile-70

Proposed by Leonardo Pistone
Status: Merged
Approved by: Yannick Vaucher @ Camptocamp
Approved revision: 119
Merged at revision: 118
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-period-lep
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 41 lines (+11/-8)
1 file modified
account_statement_ext/statement.py (+11/-8)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-7.0-fix-period-lep
Reviewer Review Type Date Requested Status
Yannick Vaucher @ Camptocamp code review + test Approve
Romain Deheele - Camptocamp (community) code review, no tests Approve
Pedro Manuel Baeza Approve
Review via email: mp+203951@code.launchpad.net

Commit message

[merge] choose real periods instead of opening ones

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

LGTM

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

I'm thinking that it's better to create a copy of the context to avoid side effects on upstream calls.

Regards.

review: Needs Fixing (code review)
117. By Leonardo Pistone

[fix] copy the context before modifying it: safer upstream

118. By Leonardo Pistone

[imp] docstring

119. By Leonardo Pistone

[fix] similarly fix another _get_period

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks Pedro, fixed.

I found a similar method on the same file and did the same fix.

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

Thank you very much!

Regards.

review: Approve
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

LGTM,

Romain

review: Approve (code review, no tests)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Thanks Leonardo

I found the same bug for one of our client in v6.1

review: Approve (code review + test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_statement_ext/statement.py'
2--- account_statement_ext/statement.py 2014-01-17 13:22:47 +0000
3+++ account_statement_ext/statement.py 2014-01-30 13:12:26 +0000
4@@ -210,11 +210,13 @@
5 return super(AccountBankSatement, self).create(cr, uid, vals, context=context)
6
7 def _get_period(self, cr, uid, date, context=None):
8- """
9- Find matching period for date, used in the statement line creation.
10- """
11+ """Return matching period for a date."""
12+ if context is None:
13+ context = {}
14 period_obj = self.pool.get('account.period')
15- periods = period_obj.find(cr, uid, dt=date, context=context)
16+ local_context = context.copy()
17+ local_context['account_period_prefer_normal'] = True
18+ periods = period_obj.find(cr, uid, dt=date, context=local_context)
19 return periods and periods[0] or False
20
21 def _check_company_id(self, cr, uid, ids, context=None):
22@@ -571,14 +573,15 @@
23 _inherit = "account.bank.statement.line"
24
25 def _get_period(self, cr, uid, context=None):
26- """
27- Return a period from a given date in the context.
28- """
29+ """Return matching period for a date."""
30 if context is None:
31 context = {}
32+ period_obj = self.pool['account.period']
33 date = context.get('date')
34+ local_context = context.copy()
35+ local_context['account_period_prefer_normal'] = True
36 try:
37- periods = self.pool.get('account.period').find(cr, uid, dt=date)
38+ periods = period_obj.find(cr, uid, dt=date, context=local_context)
39 except osv.except_osv:
40 # if no period defined, we are certainly at installation time
41 return False

Subscribers

People subscribed via source and target branches