[FIX] account_followup: corrected the followup report getting called from wizard
lp bug: https://launchpad.net/bugs/789215 fixed bzr revid: jvo@tinyerp.com-20110606101409-o08phj4cft9snpvw
This commit is contained in:
@@ -142,25 +142,22 @@ class account_followup_print_all(osv.osv_memory):
|
||||
}
|
||||
|
||||
def _get_partners_followp(self, cr, uid, ids, context=None):
|
||||
obj_acc_acc = self.pool.get("account.account")
|
||||
obj_acc_move_line = self.pool.get("account.move.line")
|
||||
data = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
if ids:
|
||||
data = self.read(cr, uid, ids, [], context=context)[0]
|
||||
cr.execute(
|
||||
"SELECT l.partner_id, l.followup_line_id,l.date_maturity, l.date, l.id "\
|
||||
"FROM account_move_line AS l "\
|
||||
"LEFT JOIN account_account AS a "\
|
||||
"ON (l.account_id=a.id) "\
|
||||
"WHERE (l.reconcile_id IS NULL) "\
|
||||
"AND (a.type='receivable') "\
|
||||
"AND (l.state<>'draft') "\
|
||||
"AND (l.partner_id is NOT NULL) "\
|
||||
"AND (a.active) "\
|
||||
"AND (l.debit > 0) "\
|
||||
"ORDER BY l.date")
|
||||
move_lines = cr.fetchall()
|
||||
old = None
|
||||
|
||||
acc_ids = obj_acc_acc.search(cr, uid, [('type','=','receivable')])
|
||||
move_line_ids = obj_acc_move_line.search(cr, uid,\
|
||||
[('account_id','in',acc_ids),('reconcile_id','=',False),\
|
||||
('state','!=','draft'),('partner_id','!=',False),\
|
||||
('debit','>',0)], order='date')
|
||||
move_line_datas = obj_acc_move_line.read(cr, uid, move_line_ids,['partner_id','date','followup_line_id','date_maturity'])
|
||||
|
||||
old = False
|
||||
fups = {}
|
||||
fup_id = 'followup_id' in context and context['followup_id'] or data['followup_id']
|
||||
date = 'date' in context and context['date'] or data['date']
|
||||
@@ -183,21 +180,22 @@ class account_followup_print_all(osv.osv_memory):
|
||||
|
||||
partner_list = []
|
||||
to_update = {}
|
||||
for partner_id, followup_line_id, date_maturity,date, id in move_lines:
|
||||
if not partner_id:
|
||||
for record in move_line_datas:
|
||||
if not record['partner_id'][0]:
|
||||
continue
|
||||
if followup_line_id not in fups:
|
||||
if (not record['followup_line_id'] and record['followup_line_id'] not in fups.keys()) or (record['followup_line_id'] and record['followup_line_id'][0] not in fups.keys()):
|
||||
continue
|
||||
if date_maturity:
|
||||
if date_maturity <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
|
||||
if partner_id not in partner_list:
|
||||
partner_list.append(partner_id)
|
||||
to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id}
|
||||
elif date and date <= fups[followup_line_id][0].strftime('%Y-%m-%d'):
|
||||
if partner_id not in partner_list:
|
||||
partner_list.append(partner_id)
|
||||
to_update[str(id)]= {'level': fups[followup_line_id][1], 'partner_id': partner_id}
|
||||
|
||||
fup_record = fups[record['followup_line_id'][0]] if record['followup_line_id'] else fups[record['followup_line_id']]
|
||||
if record['date_maturity']:
|
||||
if record['date_maturity'] <= fup_record[0].strftime('%Y-%m-%d'):
|
||||
if record['partner_id'][0] not in partner_list:
|
||||
partner_list.append(record['partner_id'][0])
|
||||
to_update[str(record['id'])]= {'level': fup_record[1], 'partner_id': record['partner_id'][0]}
|
||||
elif record['date']:
|
||||
if record['date'] <= fup_record[0].strftime('%Y-%m-%d'):
|
||||
if record['partner_id'][0] not in partner_list:
|
||||
partner_list.append(record['partner_id'][0])
|
||||
to_update[str(record['id'])]= {'level': fup_record[1],'partner_id': record['partner_id'][0]}
|
||||
return {'partner_ids': partner_list, 'to_update': to_update}
|
||||
|
||||
def do_mail(self ,cr, uid, ids, context=None):
|
||||
@@ -324,7 +322,7 @@ class account_followup_print_all(osv.osv_memory):
|
||||
date, int(id),))
|
||||
data.update({'date': context['date']})
|
||||
datas = {
|
||||
'ids': [],
|
||||
'ids': data['partner_ids'],
|
||||
'model': 'account_followup.followup',
|
||||
'form': data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user