Merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-restore_default_value into lp:banking-addons/bank-statement-reconcile-70

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Approved by: Alexandre Fayolle - camptocamp
Approved revision: 89
Merged at revision: 92
Proposed branch: lp:~camptocamp/banking-addons/bank-statement-reconcile-70-restore_default_value
Merge into: lp:banking-addons/bank-statement-reconcile-70
Diff against target: 59 lines (+22/-3) (has conflicts)
1 file modified
account_statement_ext/statement.py (+22/-3)
Text conflict in account_statement_ext/statement.py
To merge this branch: bzr merge lp:~camptocamp/banking-addons/bank-statement-reconcile-70-restore_default_value
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test, code fix Approve
Guewen Baconnier @ Camptocamp code review, no test Needs Fixing
Review via email: mp+154650@code.launchpad.net

Description of the change

Restore default period in bank statement by taking context in account

To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

invisible="True" at l.36 is weird, shouldn't it be a boolean instead of a str?

Before l.21 you should ensure that context is a dict.

review: Needs Fixing (code review, no test)
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

It is a typo. Right you are.

90. By Alexandre Fayolle - camptocamp

[FIX] value of 'invisible' argument, ensured context is a dict

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Fixed issues noted by guewen

review: Approve (code review, no test, code fix)

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 2013-04-25 11:30:23 +0000
3+++ account_statement_ext/statement.py 2013-05-24 09:28:26 +0000
4@@ -18,7 +18,10 @@
5 # along with this program. If not, see <http://www.gnu.org/licenses/>.
6 #
7 ##############################################################################
8+<<<<<<< TREE
9 import openerp.addons.account.account_bank_statement as stat_mod
10+=======
11+>>>>>>> MERGE-SOURCE
12 from openerp.osv.orm import Model
13 from openerp.osv import fields, osv
14 from openerp.tools.translate import _
15@@ -125,6 +128,16 @@
16
17 _inherit = "account.bank.statement"
18
19+ def _default_period(self, cr, uid, context=None):
20+ """
21+ Statement default period
22+ """
23+ if context is None:
24+ context = {}
25+ period_obj = self.pool.get('account.period')
26+ periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
27+ return periods and periods[0] or False
28+
29 _columns = {
30 'profile_id': fields.many2one(
31 'account.statement.profile',
32@@ -156,11 +169,15 @@
33 store=True,
34 readonly=True),
35 'period_id': fields.many2one(
36- 'account.period', 'Period', required=False, readonly=True),
37+ 'account.period',
38+ 'Period',
39+ required=False,
40+ readonly=False,
41+ invisible=True),
42 }
43
44 _defaults = {
45- 'period_id': False,
46+ 'period_id': _default_period,
47 }
48
49 def create(self, cr, uid, vals, context=None):
50@@ -536,7 +553,9 @@
51 """
52 Return a period from a given date in the context.
53 """
54- date = context.get('date', None)
55+ if context is None:
56+ context = {}
57+ date = context.get('date')
58 periods = self.pool.get('account.period').find(cr, uid, dt=date)
59 return periods and periods[0] or False
60

Subscribers

People subscribed via source and target branches