Add date choice for write-off on manual reconciliation

Registered by André Kurz (Hasa.ch)

When we pay and reconcile an invoice, the date of payment is used as the write-off date, but when we reconcile manually with the wizard account/wizard/wizard_reconcile.py, the date for the write-off is the date of the day when we reconcile it, even if the payment was done a few weeks/months ago.

There should be a date field for the write-off when we manually reconcile entries.

It is possible to do that with these new lines of code. I also add code to get the most recent date of the account move lines which should be the payment date. This date can still be changed in the reconcile form, it is just an extra.

--- /usr/lib/python2.5/site-packages/openerp-server/addons/account/wizard/wizard_reconcile_orig.py 2009-02-18 15:55:09.000000000 +0100
+++ /usr/lib/python2.5/site-packages/openerp-server/addons/account/wizard/wizard_reconcile.py 2009-07-23 14:27:10.000000000 +0200
@@ -67,11 +67,11 @@
 def _trans_rec_reconcile(self, cr, uid, data, context=None):
     pool = pooler.get_pool(cr.dbname)
     account_move_line_obj = pool.get('account.move.line')
-
     form = data['form']
     account_id = form.get('writeoff_acc_id', False)
     period_id = form.get('period_id', False)
     journal_id = form.get('journal_id', False)
+ context['date_p'] = form.get('date_p', False)
     account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
             period_id, journal_id, context=context)
     return {}
@@ -85,6 +85,7 @@
 <form string="Information addendum">
     <separator string="Write-Off Move" colspan="4"/>
     <field name="journal_id"/>
+ <field name="date_p"/>
     <field name="period_id"/>
     <field name="writeoff_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
 </form>'''
@@ -93,6 +94,7 @@
     'journal_id': {'string': 'Write-Off Journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
     'period_id': {'string': 'Write-Off Period', 'type': 'many2one', 'relation':'account.period', 'required':True},
     'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
+ 'date_p': {'string':'Date','type':'date'},
 }

 def _trans_rec_addendum(self, cr, uid, data, context={}):
@@ -101,7 +103,17 @@
     period_id = False
     if len(ids):
         period_id = ids[0]
- return {'period_id':period_id}
+ #get the more recent date of the account.move.line selected
+ first = True
+ for ml in data['ids'] :
+ date_ml = pool.get('account.move.line').read(cr, uid, ml,['date'])['date']
+ if first :
+ first = False
+ date_p = date_ml
+ if not first :
+ if date_ml > date_p :
+ date_p = date_ml
+ return {'period_id':period_id, 'date_p':date_p}

 class wiz_reconcile(wizard.interface):

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.