[ADD] account_easy_reconcile: jump buttons to display the move lines

and display the count of move lines
This commit is contained in:
@
2012-12-19 16:40:41 +01:00
committed by mpanarin
parent cbcd0b98dc
commit 87fbc31538
4 changed files with 107 additions and 27 deletions

View File

@@ -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()

View File

@@ -20,9 +20,28 @@
<notebook colspan="4">
<page name="methods" string="Configuration">
<field name="reconcile_method" colspan = "4" nolabel="1"/>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
string="Start Auto Reconcilation" type="object"/>
<button icon="STOCK_JUMP_TO" name="last_history_reconcile" colspan="2"
string="Display items reconciled on the last run" type="object"/>
<button icon="STOCK_JUMP_TO" name="last_history_partial" colspan="2"
string="Display items partially reconciled on the last run"
type="object"/>
</page>
<page name="history" string="History">
<field name="history_ids" nolabel="1"/>
<field name="history_ids" nolabel="1">
<tree string="Automatic Easy Reconcile History">
<field name="date"/>
<!-- display the count of lines -->
<field name="reconcile_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_reconcile"
string="Go to reconciled items" type="object"/>
<!-- display the count of lines -->
<field name="partial_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_partial"
string="Go to partially reconciled items" type="object"/>
</tree>
</field>
</page>
<page name="information" string="Information">
<separator colspan="4" string="Simple. Amount and Name"/>
@@ -35,8 +54,6 @@ The lines should have the same amount (with the write-off) and the same partner
</page>
</notebook>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
string="Start Auto Reconcilation" type="object"/>
</form>
</field>
</record>
@@ -55,6 +72,11 @@ The lines should have the same amount (with the write-off) and the same partner
<field name="reconciled_partial_count"/>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
string="Start Auto Reconcilation" type="object"/>
<button icon="STOCK_JUMP_TO" name="last_history_reconcile" colspan="2"
string="Display items reconciled on the last run" type="object"/>
<button icon="STOCK_JUMP_TO" name="last_history_partial" colspan="2"
string="Display items partially reconciled on the last run"
type="object"/>
</tree>
</field>
</record>

View File

@@ -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):

View File

@@ -50,8 +50,8 @@
<field name="reconcile_partial_ids" nolabel="1"/>
</group>
<group col="2" colspan="4">
<button icon="gtk-ok" name="open_reconcile" string="Go to reconciled entries" type="object"/>
<button icon="gtk-ok" name="open_partial" string="Go to partially reconciled entries" type="object"/>
<button icon="STOCK_JUMP_TO" name="open_reconcile" string="Go to reconciled items" type="object"/>
<button icon="STOCK_JUMP_TO" name="open_partial" string="Go to partially reconciled items" type="object"/>
</group>
</form>
</field>
@@ -66,6 +66,14 @@
<tree string="Automatic Easy Reconcile History">
<field name="easy_reconcile_id"/>
<field name="date"/>
<!-- display the count of lines -->
<field name="reconcile_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_reconcile"
string="Go to reconciled items" type="object"/>
<!-- display the count of lines -->
<field name="partial_line_ids"/>
<button icon="STOCK_JUMP_TO" name="open_partial"
string="Go to partially reconciled items" type="object"/>
</tree>
</field>
</record>