[IMP] account
bzr revid: mra@tinyerp.com-20100520122418-x5tj5nmvmyf3b0ny
This commit is contained in:
parent
917eb7cafa
commit
ecd8f4b46e
|
@ -65,14 +65,11 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
def check2(value, move_list, power):
|
||||
print "::::::check2::::::::::",value, move_list, power
|
||||
def check(value, move_list, power):
|
||||
for i in range(len(move_list)):
|
||||
move = move_list[i]
|
||||
print "::::::::::::::::::",value,max_amount,move,move[1]
|
||||
if power == 1:
|
||||
if abs(value - move[1]) <= max_amount + 0.00001:
|
||||
print "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^6"
|
||||
return [move[0]]
|
||||
else:
|
||||
del move_list[i]
|
||||
|
@ -94,7 +91,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
# depending on the power. It starts with a power of one and goes up
|
||||
# to the max power allowed
|
||||
def check4(list1, list2, power):
|
||||
print "::::::check4::::::::::",list1, list2, power
|
||||
def check3(value, list1, list2, list1power, power):
|
||||
for i in range(len(list1)):
|
||||
move = list1[i]
|
||||
|
@ -119,12 +115,9 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
return False
|
||||
|
||||
def check5(list1, list2, max_power):
|
||||
print "\n\n%%%%%%%%check5%%%%%%%%%%%%%%%%%%%",list1,list2,max_power
|
||||
for p in range(2, max_power+1):
|
||||
res = check4(list1, list2, p)
|
||||
print "RRRRRRRcheck5RRRRRRRR",res
|
||||
if res:
|
||||
print "RRRRRRcheck5REtrunrn...",res
|
||||
return res
|
||||
|
||||
ok = True
|
||||
|
@ -132,12 +125,10 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
while credits and debits and ok:
|
||||
res = check5(credits, debits, power)
|
||||
if res:
|
||||
print "Finallllllllllll RES",res
|
||||
move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context)
|
||||
reconciled += len(res[0]) + len(res[1])
|
||||
credits = [(id, credit) for (id, credit) in credits if id not in res[0]]
|
||||
debits = [(id, debit) for (id, debit) in debits if id not in res[1]]
|
||||
print "=================================",reconciled,credits,debits
|
||||
else:
|
||||
ok = False
|
||||
return (reconciled, len(credits)+len(debits))
|
||||
|
@ -154,7 +145,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
reconciled = unreconciled = 0
|
||||
if not form['account_ids']:
|
||||
raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile'))
|
||||
print ">>>>START<<<<\n",form['account_ids']
|
||||
for account_id in form['account_ids']:
|
||||
# reconcile automatically all transactions from partners whose balance is 0
|
||||
cr.execute(
|
||||
|
@ -167,7 +157,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0",
|
||||
(account_id, max_amount or 0.0))
|
||||
partner_ids = [id for (id,) in cr.fetchall()]
|
||||
print "partner_ids:::::::::::::::::::::::::>>>",partner_ids
|
||||
for partner_id in partner_ids:
|
||||
cr.execute(
|
||||
"SELECT id " \
|
||||
|
@ -178,7 +167,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"AND reconcile_id IS NULL",
|
||||
(account_id, partner_id))
|
||||
line_ids = [id for (id,) in cr.fetchall()]
|
||||
print "LLLLLLLLLLLLLLLLLLLLline idsssss....",line_ids
|
||||
if len(line_ids):
|
||||
move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
||||
reconciled += len(line_ids)
|
||||
|
@ -195,7 +183,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"HAVING count(*)>1",
|
||||
(account_id,))
|
||||
partner_ids = [id for (id,) in cr.fetchall()]
|
||||
print "second partner idssssssssssssss",partner_ids
|
||||
#filter?
|
||||
for partner_id in partner_ids:
|
||||
# get the list of unreconciled 'debit transactions' for this partner
|
||||
|
@ -209,7 +196,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"AND debit > 0",
|
||||
(account_id, partner_id))
|
||||
debits = cr.fetchall()
|
||||
print "UUUUUUUUUUUUUUUUUU Debitssssssss",debits
|
||||
|
||||
# get the list of unreconciled 'credit transactions' for this partner
|
||||
cr.execute(
|
||||
|
@ -222,17 +208,14 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"AND credit > 0",
|
||||
(account_id, partner_id))
|
||||
credits = cr.fetchall()
|
||||
print "CCCCCCCCCCCCCCCCCCcreditttt.....",credits
|
||||
|
||||
(rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
|
||||
print "()(()(((rec, unrec))((()()()",(rec, unrec)
|
||||
reconciled += rec
|
||||
unreconciled += unrec
|
||||
|
||||
# add the number of transactions for partners who have only one
|
||||
# unreconciled transactions to the unreconciled count
|
||||
partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
|
||||
print "Partner fileterrrrrrrrrrrr",partner_filter
|
||||
cr.execute(
|
||||
"SELECT count(*) " \
|
||||
"FROM account_move_line " \
|
||||
|
@ -241,7 +224,6 @@ class account_automatic_reconcile(osv.osv_memory):
|
|||
"AND state <> 'draft' " + partner_filter,
|
||||
(account_id,))
|
||||
additional_unrec = cr.fetchone()[0]
|
||||
print "^^^^^^^^^^^^^^^^^^^^^",additional_unrec
|
||||
context.update({'reconciled': reconciled, 'unreconciled': unreconciled + additional_unrec})
|
||||
model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')])
|
||||
resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
|
||||
|
|
|
@ -29,7 +29,7 @@ class account_unreconcile(osv.osv_memory):
|
|||
obj_move_reconcile = self.pool.get('account.move.reconcile')
|
||||
if context is None:
|
||||
context = {}
|
||||
recs = pool.get('account.move.line').read(cr, uid, data['ids'], ['reconcile_id','reconcile_partial_id'])
|
||||
recs = obj_move_line.read(cr, uid, data['ids'], ['reconcile_id','reconcile_partial_id'])
|
||||
unlink_ids = []
|
||||
full_recs = filter(lambda x: x['reconcile_id'], recs)
|
||||
rec_ids = [rec['reconcile_id'][0] for rec in full_recs]
|
||||
|
@ -37,9 +37,9 @@ class account_unreconcile(osv.osv_memory):
|
|||
part_rec_ids = [rec['reconcile_partial_id'][0] for rec in part_recs]
|
||||
unlink_ids += rec_ids
|
||||
unlink_ids += part_rec_ids
|
||||
|
||||
|
||||
if len(unlink_ids):
|
||||
pooler.get_pool(cr.dbname).get('account.move.reconcile').unlink(cr, uid, unlink_ids)
|
||||
self.pool.get('account.move.reconcile').unlink(cr, uid, unlink_ids)
|
||||
return {}
|
||||
|
||||
account_unreconcile()
|
||||
|
|
Loading…
Reference in New Issue