[FIX] account, reconciliation manul process: multi fixes (division by 0, put a condition on stopping the process for a partner, corrected stats and process in order to not show partners with only debit (or credit) entries
bzr revid: qdp-launchpad@tinyerp.com-20100923114315-px7xcih1tv8ic1n1
This commit is contained in:
parent
1b914d691c
commit
4f294bb583
|
@ -639,6 +639,7 @@ class account_move_line(osv.osv):
|
|||
AND l.state <> 'draft'
|
||||
GROUP BY l.partner_id
|
||||
) AS s ON (p.id = s.partner_id)
|
||||
WHERE debit > 0 AND credit > 0
|
||||
ORDER BY p.last_reconciliation_date LIMIT 1 OFFSET %s""", (offset,)
|
||||
)
|
||||
return cr.fetchone()
|
||||
|
|
|
@ -85,7 +85,19 @@ class account_move_line_reconcile(osv.osv_memory):
|
|||
ids = self.pool.get('account.period').find(cr, uid, dt=date, context=context)
|
||||
if len(ids):
|
||||
period_id = ids[0]
|
||||
context.update({'stop_reconcile': True})
|
||||
#stop the reconciliation process by partner (manual reconciliation) only if there is nothing more to reconcile for this partner
|
||||
if 'active_ids' in context and context['active_ids']:
|
||||
tmp_ml_id = account_move_line_obj.browse(cr, uid, context['active_ids'], context)[0]
|
||||
partner_id = tmp_ml_id.partner_id and tmp_ml_id.partner_id.id or False
|
||||
debit_ml_ids = account_move_line_obj.search(cr, uid, [('partner_id', '=', partner_id), ('account_id.reconcile', '=', True), ('reconcile_id', '=', False), ('debit', '>', 0)], context=context)
|
||||
credit_ml_ids = account_move_line_obj.search(cr, uid, [('partner_id', '=', partner_id), ('account_id.reconcile', '=', True), ('reconcile_id', '=', False), ('credit', '>', 0)], context=context)
|
||||
for ml_id in context['active_ids']:
|
||||
if ml_id in debit_ml_ids:
|
||||
debit_ml_ids.remove(ml_id)
|
||||
if ml_id in credit_ml_ids:
|
||||
credit_ml_ids.remove(ml_id)
|
||||
if not (len(debit_ml_ids) and len(credit_ml_ids)):
|
||||
context.update({'stop_reconcile': True})
|
||||
account_move_line_obj.reconcile(cr, uid, context['active_ids'], 'manual', account_id,
|
||||
period_id, journal_id, context=context)
|
||||
return {}
|
||||
|
|
|
@ -28,14 +28,18 @@ class account_partner_reconcile_process(osv.osv_memory):
|
|||
_description = 'Reconcilation Process partner by partner'
|
||||
|
||||
def _get_to_reconcile(self, cr, uid, context=None):
|
||||
cr.execute(
|
||||
"SELECT l.partner_id " \
|
||||
"FROM account_move_line AS l LEFT JOIN res_partner p ON (p.id = l.partner_id) " \
|
||||
"WHERE l.reconcile_id IS NULL " \
|
||||
"AND (%s > to_char(p.last_reconciliation_date, 'YYYY-MM-DD') " \
|
||||
"OR p.last_reconciliation_date IS NULL ) " \
|
||||
"AND l.state <> 'draft' " \
|
||||
"GROUP BY l.partner_id ",(time.strftime('%Y-%m-%d'),)
|
||||
cr.execute("""
|
||||
SELECT p_id FROM (SELECT l.partner_id as p_id, SUM(l.debit) AS debit, SUM(l.credit) AS credit
|
||||
FROM account_move_line AS l LEFT JOIN account_account a ON (l.account_id = a.id)
|
||||
LEFT JOIN res_partner p ON (p.id = l.partner_id)
|
||||
WHERE a.reconcile = 't'
|
||||
AND l.reconcile_id IS NULL
|
||||
AND (%s > to_char(p.last_reconciliation_date, 'YYYY-MM-DD') OR p.last_reconciliation_date IS NULL )
|
||||
AND l.state <> 'draft'
|
||||
GROUP BY l.partner_id) AS tmp
|
||||
WHERE debit > 0
|
||||
AND credit > 0
|
||||
""",(time.strftime('%Y-%m-%d'),)
|
||||
)
|
||||
return len(map(lambda x: x[0], cr.fetchall())) - 1
|
||||
|
||||
|
@ -57,7 +61,7 @@ class account_partner_reconcile_process(osv.osv_memory):
|
|||
return partner[0]
|
||||
|
||||
def data_get(self, cr, uid, to_reconcile, today_reconciled, context=None):
|
||||
return {'progress': (100 / float(to_reconcile + today_reconciled)) * today_reconciled}
|
||||
return {'progress': (100 / (float(to_reconcile + today_reconciled) or 1.0)) * today_reconciled}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
res = super(account_partner_reconcile_process, self).default_get(cr, uid, fields, context=context)
|
||||
|
|
Loading…
Reference in New Issue