Merge lp:~camptocamp/banking-addons/6.1-banking-addons-statement-reconcile-account_easy_reconcile-empty_history-1095677 into lp:banking-addons/bank-statement-reconcile-61

Proposed by Guewen Baconnier @ Camptocamp
Status: Merged
Merged at revision: 76
Proposed branch: lp:~camptocamp/banking-addons/6.1-banking-addons-statement-reconcile-account_easy_reconcile-empty_history-1095677
Merge into: lp:banking-addons/bank-statement-reconcile-61
Diff against target: 49 lines (+18/-2)
1 file modified
account_easy_reconcile/easy_reconcile.py (+18/-2)
To merge this branch: bzr merge lp:~camptocamp/banking-addons/6.1-banking-addons-statement-reconcile-account_easy_reconcile-empty_history-1095677
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Joël Grand-Guillaume @ camptocamp Approve
Review via email: mp+141765@code.launchpad.net

Description of the change

fix lp:1095677

The fix for the 7 version will be included in the migration of the module that I'm currently doing.

To post a comment you must log in.
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM

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

LGTM

review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account_easy_reconcile/easy_reconcile.py'
2--- account_easy_reconcile/easy_reconcile.py 2012-12-20 11:05:28 +0000
3+++ account_easy_reconcile/easy_reconcile.py 2013-01-03 15:30:31 +0000
4@@ -140,8 +140,10 @@
5 def _last_history(self, cr, uid, ids, name, args, context=None):
6 result = {}
7 for history in self.browse(cr, uid, ids, context=context):
8- # history is sorted by date desc
9- result[history.id] = history.history_ids[0].id
10+ result[history.id] = False
11+ if history.history_ids:
12+ # history is sorted by date desc
13+ result[history.id] = history.history_ids[0].id
14 return result
15
16 _columns = {
17@@ -222,6 +224,16 @@
18 context=context)
19 return True
20
21+ def _no_history(self, cr, uid, rec, context=None):
22+ """ Raise an `osv.except_osv` error, supposed to
23+ be called when there is no history on the reconciliation
24+ task.
25+ """
26+ raise osv.except_osv(
27+ _('Error'),
28+ _('There is no history of reconciled '
29+ 'entries on the task: %s.') % rec.name)
30+
31 def last_history_reconcile(self, cr, uid, rec_id, context=None):
32 """ Get the last history record for this reconciliation profile
33 and return the action which opens move lines reconciled
34@@ -231,6 +243,8 @@
35 "Only 1 id expected"
36 rec_id = rec_id[0]
37 rec = self.browse(cr, uid, rec_id, context=context)
38+ if not rec.last_history:
39+ self._no_history(cr, uid, rec, context=context)
40 return rec.last_history.open_reconcile()
41
42 def last_history_partial(self, cr, uid, rec_id, context=None):
43@@ -242,4 +256,6 @@
44 "Only 1 id expected"
45 rec_id = rec_id[0]
46 rec = self.browse(cr, uid, rec_id, context=context)
47+ if not rec.last_history:
48+ self._no_history(cr, uid, rec, context=context)
49 return rec.last_history.open_partial()

Subscribers

People subscribed via source and target branches