diff --git a/account_easy_reconcile/easy_reconcile.py b/account_easy_reconcile/easy_reconcile.py
index 53b7cf42..979a187d 100644
--- a/account_easy_reconcile/easy_reconcile.py
+++ b/account_easy_reconcile/easy_reconcile.py
@@ -206,7 +206,7 @@ class account_easy_reconcile(Model):
partial_ids = find_reconcile_ids(
'reconcile_partial_id', all_ml_partial_ids)
- history_id = self.pool.get('easy.reconcile.history').create(
+ self.pool.get('easy.reconcile.history').create(
cr,
uid,
{'easy_reconcile_id': rec.id,
@@ -214,15 +214,30 @@ class account_easy_reconcile(Model):
'reconcile_ids': [(4, rid) for rid in reconcile_ids],
'reconcile_partial_ids': [(4, rid) for rid in partial_ids]},
context=context)
+ return True
- return {
- 'name':_("Reconciliations"),
- 'view_mode': 'tree,form', # FIXME: In OpenERP 6.1 we can't display
- 'view_id': False, # only the form, check in version 7.0
- 'view_type': 'form',
- 'res_model': 'easy.reconcile.history',
- 'type': 'ir.actions.act_window',
- 'nodestroy': True,
- 'target': 'current',
- 'domain': unicode([('id', '=', history_id)]),
- }
+ def last_history_reconcile(self, cr, uid, rec_id, context=None):
+ """ Get the last history record for this reconciliation profile
+ and return the action which opens move lines reconciled
+ """
+ if isinstance(rec_id, (tuple, list)):
+ assert len(rec_id) == 1, \
+ "Only 1 id expected"
+ rec_id = rec_id[0]
+ rec = self.browse(cr, uid, rec_id, context=context)
+ # the history is ordered by date desc
+ last_history = rec.history_ids[0]
+ return last_history.open_reconcile()
+
+ def last_history_partial(self, cr, uid, rec_id, context=None):
+ """ Get the last history record for this reconciliation profile
+ and return the action which opens move lines reconciled
+ """
+ if isinstance(rec_id, (tuple, list)):
+ assert len(rec_id) == 1, \
+ "Only 1 id expected"
+ rec_id = rec_id[0]
+ rec = self.browse(cr, uid, rec_id, context=context)
+ # the history is ordered by date desc
+ last_history = rec.history_ids[0]
+ return last_history.open_partial()
diff --git a/account_easy_reconcile/easy_reconcile.xml b/account_easy_reconcile/easy_reconcile.xml
index 6c3bc820..7f7f8334 100644
--- a/account_easy_reconcile/easy_reconcile.xml
+++ b/account_easy_reconcile/easy_reconcile.xml
@@ -20,9 +20,28 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -35,8 +54,6 @@ The lines should have the same amount (with the write-off) and the same partner
-
@@ -55,6 +72,11 @@ The lines should have the same amount (with the write-off) and the same partner
+
+
diff --git a/account_easy_reconcile/easy_reconcile_history.py b/account_easy_reconcile/easy_reconcile_history.py
index 7dbbdf30..1da24ca0 100644
--- a/account_easy_reconcile/easy_reconcile_history.py
+++ b/account_easy_reconcile/easy_reconcile_history.py
@@ -31,6 +31,30 @@ class easy_reconcile_history(orm.Model):
_rec_name = 'easy_reconcile_id'
_order = 'date DESC'
+ def _reconcile_line_ids(self, cr, uid, ids, name, args, context=None):
+ result = {}
+
+ for history in self.browse(cr, uid, ids, context=context):
+ result[history.id] = {}
+
+ move_line_ids = []
+ for reconcile in history.reconcile_ids:
+ move_line_ids.extend(
+ [line.id
+ for line
+ in reconcile.line_id])
+ result[history.id]['reconcile_line_ids'] = move_line_ids
+
+ move_line_ids = []
+ for reconcile in history.reconcile_partial_ids:
+ move_line_ids.extend(
+ [line.id
+ for line
+ in reconcile.line_partial_ids])
+ result[history.id]['partial_line_ids'] = move_line_ids
+
+ return result
+
_columns = {
'easy_reconcile_id': fields.many2one(
'account.easy.reconcile', 'Reconcile Profile', readonly=True),
@@ -43,6 +67,22 @@ class easy_reconcile_history(orm.Model):
'account.move.reconcile',
'account_move_reconcile_history_partial_rel',
string='Partial Reconciliations', readonly=True),
+ 'reconcile_line_ids':
+ fields.function(
+ _reconcile_line_ids,
+ string='Reconciled Items',
+ type='many2many',
+ relation='account.move.line',
+ readonly=True,
+ multi='lines'),
+ 'partial_line_ids':
+ fields.function(
+ _reconcile_line_ids,
+ string='Partially Reconciled Items',
+ type='many2many',
+ relation='account.move.line',
+ readonly=True,
+ multi='lines'),
}
def _open_move_lines(self, cr, uid, history_id, rec_type='full', context=None):
@@ -59,19 +99,14 @@ class easy_reconcile_history(orm.Model):
history = self.browse(cr, uid, history_id, context=context)
if rec_type == 'full':
- field = 'reconcile_ids'
- rec_field = 'line_id'
+ field = 'reconcile_line_ids'
name = _('Reconciliations')
else:
- field = 'reconcile_partial_ids'
- rec_field = 'line_partial_ids'
+ field = 'partial_line_ids'
name = _('Partial Reconciliations')
- move_line_ids = []
- for reconcile in getattr(history, field):
- move_line_ids.extend(
- [line.id for line
- in getattr(reconcile, rec_field)])
+ move_line_ids = [line.id for line in getattr(history, field)]
+
return {
'name': name,
'view_mode': 'tree,form',
@@ -81,7 +116,7 @@ class easy_reconcile_history(orm.Model):
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
- 'domain': unicode([('id', '=', move_line_ids)]),
+ 'domain': unicode([('id', 'in', move_line_ids)]),
}
def open_reconcile(self, cr, uid, history_ids, context=None):
diff --git a/account_easy_reconcile/easy_reconcile_history_view.xml b/account_easy_reconcile/easy_reconcile_history_view.xml
index a15765f0..29b484ae 100644
--- a/account_easy_reconcile/easy_reconcile_history_view.xml
+++ b/account_easy_reconcile/easy_reconcile_history_view.xml
@@ -50,8 +50,8 @@
-
-
+
+
@@ -66,6 +66,14 @@
+
+
+
+
+
+