[FIX][IMP] Correct write-off date, add analytic account, better interface between all way to reconcile

lp bug: https://launchpad.net/bugs/435160 fixed

bzr revid: joel.grandguillaume@camptocamp.com-20091102084000-h21k703spch2hqxl
This commit is contained in:
rvalyi 2009-11-02 09:40:00 +01:00 committed by Joel Grand-Guillaume
parent c64e10c4fa
commit 7a2cbc32de
3 changed files with 33 additions and 16 deletions

View File

@ -616,6 +616,7 @@ class account_move_line(osv.osv):
'debit':debit,
'credit':credit,
'account_id':writeoff_acc_id,
'analytic_account_id': context.get('analytic_id', False),
'date':date,
'partner_id':partner_id
})
@ -624,7 +625,7 @@ class account_move_line(osv.osv):
writeoff_move_id = self.pool.get('account.move').create(cr, uid, {
'period_id': writeoff_period_id,
'journal_id': writeoff_journal_id,
'date':date,
'state': 'draft',
'line_id': writeoff_lines
})
@ -869,7 +870,7 @@ class account_move_line(osv.osv):
'amount': vals['debit'] or vals['credit'],
'general_account_id': vals['account_id'],
'journal_id': journal.analytic_journal_id.id,
'ref': vals['ref'],
'ref': vals.get('ref', False),
})]
#else:
# raise osv.except_osv(_('No analytic journal !'), _('Please set an analytic journal on this financial journal !'))

View File

@ -53,6 +53,7 @@ def _pay_and_reconcile(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
cur_obj = pool.get('res.currency')
amount = form['amount']
context['analytic_id'] = form.get('analytic_id', False)
invoice = pool.get('account.invoice').browse(cr, uid, data['id'], context)
journal = pool.get('account.journal').browse(cr, uid, data['form']['journal_id'], context)
@ -62,9 +63,9 @@ def _pay_and_reconcile(self, cr, uid, data, context):
# Take the choosen date
if form.has_key('comment'):
context={'date_p':form['date'],'comment':form['comment']}
context.update({'date_p':form['date'],'comment':form['comment']})
else:
context={'date_p':form['date'],'comment':False}
context.update({'date_p':form['date'],'comment':False})
acc_id = journal.default_credit_account_id and journal.default_credit_account_id.id
if not acc_id:
@ -90,19 +91,22 @@ def _wo_check(self, cr, uid, data, context):
_transaction_add_form = '''<?xml version="1.0"?>
<form string="Information addendum">
<separator string="Write-Off Move" colspan="4"/>
<field name="writeoff_acc_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="writeoff_journal_id"/>
<field name="writeoff_acc_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
<field name="comment"/>
<separator string="Analytic" colspan="4"/>
<field name="analytic_id"/>
</form>'''
_transaction_add_fields = {
'writeoff_acc_id': {'string':'Write-Off account', 'type':'many2one', 'relation':'account.account', 'required':True},
'writeoff_journal_id': {'string': 'Write-Off journal', 'type': 'many2one', 'relation':'account.journal', 'required':True},
'comment': {'string': 'Entry Name', 'type':'char', 'size': 64, 'required':True},
'comment': {'string': 'Comment', 'type':'char', 'size': 64 , 'required':True},
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
}
def _get_value_addendum(self, cr, uid, data, context={}):
return {}
return {'comment': _('Write-Off')}
def _get_period(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)

View File

@ -25,6 +25,7 @@ import netsvc
import time
import osv
import pooler
from mx import DateTime
_transaction_form = '''<?xml version="1.0"?>
<form string="Reconciliation">
@ -70,8 +71,18 @@ def _trans_rec_reconcile(self, cr, uid, data, context=None):
form = data['form']
account_id = form.get('writeoff_acc_id', False)
period_id = form.get('period_id', False)
context['date_p'] = form.get('date_p', False)
date = False
if context['date_p']:
date = DateTime.strptime(context['date_p'], '%Y-%m-%d')
ids = pool.get('account.period').find(cr, uid, dt=date, context=context)
period_id = False
if len(ids):
period_id = ids[0]
journal_id = form.get('journal_id', False)
context['comment'] = form.get('comment', False)
context['analytic_id'] = form.get('analytic_id', False)
account_move_line_obj.reconcile(cr, uid, data['ids'], 'manual', account_id,
period_id, journal_id, context=context)
return {}
@ -85,23 +96,24 @@ _transaction_add_form = '''<?xml version="1.0"?>
<form string="Information addendum">
<separator string="Write-Off Move" colspan="4"/>
<field name="journal_id"/>
<field name="period_id"/>
<field name="writeoff_acc_id" domain="[('type', '&lt;&gt;', 'view')]"/>
<field name="date_p"/>
<field name="comment"/>
<separator string="Analytic" colspan="4"/>
<field name="analytic_id"/>
</form>'''
_transaction_add_fields = {
'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'},
'comment': {'string':'Comment','type':'char', 'size': 64},
'analytic_id': {'string':'Analytic Account', 'type': 'many2one', 'relation':'account.analytic.account'},
}
def _trans_rec_addendum(self, cr, uid, data, context={}):
pool = pooler.get_pool(cr.dbname)
ids = pool.get('account.period').find(cr, uid, context=context)
period_id = False
if len(ids):
period_id = ids[0]
return {'period_id':period_id}
date_p = time.strftime('%Y-%m-%d')
return {'date_p':date_p, 'comment': _('Write-Off')}
class wiz_reconcile(wizard.interface):