[ADD] account_easy_reconcile: open move lines of a reconciliation run

This commit is contained in:
@
2012-12-19 15:25:01 +01:00
committed by mpanarin
parent d5ce7effc2
commit cbcd0b98dc
3 changed files with 91 additions and 6 deletions

View File

@@ -35,7 +35,8 @@ 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"/>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
string="Start Auto Reconcilation" type="object"/>
</form>
</field>
</record>
@@ -52,6 +53,8 @@ The lines should have the same amount (with the write-off) and the same partner
<field name="scheduler"/>
<field name="unreconciled_count"/>
<field name="reconciled_partial_count"/>
<button icon="gtk-ok" name="run_reconcile" colspan="4"
string="Start Auto Reconcilation" type="object"/>
</tree>
</field>
</record>

View File

@@ -20,6 +20,7 @@
##############################################################################
from openerp.osv import orm, fields
from openerp.tools.translate import _
class easy_reconcile_history(orm.Model):
@@ -43,3 +44,70 @@ class easy_reconcile_history(orm.Model):
'account_move_reconcile_history_partial_rel',
string='Partial Reconciliations', readonly=True),
}
def _open_move_lines(self, cr, uid, history_id, rec_type='full', context=None):
""" For an history record, open the view of move line with
the reconciled or partially reconciled move lines
:param history_id: id of the history
:param rec_type: 'full' or 'partial'
:return: action to open the move lines
"""
assert rec_type in ('full', 'partial'), \
"rec_type must be 'full' or 'partial'"
history = self.browse(cr, uid, history_id, context=context)
if rec_type == 'full':
field = 'reconcile_ids'
rec_field = 'line_id'
name = _('Reconciliations')
else:
field = 'reconcile_partial_ids'
rec_field = 'line_partial_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)])
return {
'name': name,
'view_mode': 'tree,form',
'view_id': False,
'view_type': 'form',
'res_model': 'account.move.line',
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'domain': unicode([('id', '=', move_line_ids)]),
}
def open_reconcile(self, cr, uid, history_ids, context=None):
""" For an history record, open the view of move line
with the reconciled move lines
:param history_ids: id of the record as int or long
Accept a list with 1 id too to be
used from the client.
"""
if isinstance(history_ids, (tuple, list)):
assert len(history_ids) == 1, "only 1 ID is accepted"
history_ids = history_ids[0]
return self._open_move_lines(
cr, uid, history_ids, rec_type='full', context=None)
def open_partial(self, cr, uid, history_ids, context=None):
""" For an history record, open the view of move line
with the partially reconciled move lines
:param history_ids: id of the record as int or long
Accept a list with 1 id too to be
used from the client.
"""
if isinstance(history_ids, (tuple, list)):
assert len(history_ids) == 1, "only 1 ID is accepted"
history_ids = history_ids[0]
return self._open_move_lines(
cr, uid, history_ids, rec_type='partial', context=None)

View File

@@ -41,8 +41,18 @@
<form string="Automatic Easy Reconcile History">
<field name="easy_reconcile_id"/>
<field name="date"/>
<field name="reconcile_ids"/>
<field name="reconcile_partial_ids"/>
<group colspan="2" col="2">
<separator colspan="2" string="Reconcilations"/>
<field name="reconcile_ids" nolabel="1"/>
</group>
<group colspan="2" col="2">
<separator colspan="2" string="Partial Reconcilations"/>
<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"/>
</group>
</form>
</field>
</record>
@@ -68,9 +78,13 @@
<field name="view_mode">tree,form</field>
</record>
<menuitem action="action_easy_reconcile_history"
id="menu_easy_reconcile_history"
parent="account.periodical_processing_reconciliation"/>
<act_window
context="{'search_default_easy_reconcile_id': [active_id], 'default_easy_reconcile_id': active_id}"
id="act_easy_reconcile_to_history"
name="History Details"
groups=""
res_model="easy.reconcile.history"
src_model="account.easy.reconcile"/>
</data>
</openerp>