Merge lp:~openerp-dev/openobject-addons/pap_autoreconcile_partial into lp:~openerp-dev/openobject-addons/trunk-dev-addons3

Proposed by pap(openerp)
Status: Merged
Merge reported by: Mustufa Rangwala (Open ERP)
Merged at revision: not available
Proposed branch: lp:~openerp-dev/openobject-addons/pap_autoreconcile_partial
Merge into: lp:~openerp-dev/openobject-addons/trunk-dev-addons3
Diff against target: 101 lines (+77/-0) (has conflicts)
1 file modified
account/wizard/account_automatic_reconcile.py (+77/-0)
Text conflict in account/wizard/account_automatic_reconcile.py
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/pap_autoreconcile_partial
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+27484@code.launchpad.net

This proposal supersedes a proposal from 2010-06-14.

Description of the change

added code for partial reconciliation in automatic reconciliation wizard
backlog_id = 227

To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote : Posted in a previous version of this proposal

thanks your changes has been merged with dev3 branch

Mustufa (mra)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/wizard/account_automatic_reconcile.py'
2--- account/wizard/account_automatic_reconcile.py 2010-06-14 09:17:41 +0000
3+++ account/wizard/account_automatic_reconcile.py 2010-06-14 10:39:32 +0000
4@@ -145,6 +145,19 @@
5 if not form['account_ids']:
6 raise osv.except_osv(_('UserError'), _('You must select accounts to reconcile'))
7 for account_id in form['account_ids']:
8+<<<<<<< TREE
9+=======
10+ if not context.get('allow_write_off', False):
11+ query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
12+ AND state <> 'draft' GROUP BY partner_id \
13+ HAVING ABS(SUM(debit-credit)) <> %s AND count(*)>0"%(account_id, 0.0)
14+# query="SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
15+# AND state <> 'draft' GROUP BY partner_id AND debit = credi"%(account_id)
16+ else:
17+ query = "SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL \
18+ AND state <> 'draft' GROUP BY partner_id \
19+ HAVING ABS(SUM(debit-credit)) <= %s AND count(*)>0"%(account_id, max_amount or 0.0)
20+>>>>>>> MERGE-SOURCE
21 # reconcile automatically all transactions from partners whose balance is 0
22 cr.execute(
23 "SELECT partner_id " \
24@@ -167,6 +180,7 @@
25 (account_id, partner_id))
26 line_ids = [id for (id,) in cr.fetchall()]
27 if len(line_ids):
28+<<<<<<< TREE
29 move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
30 reconciled += len(line_ids)
31
32@@ -224,6 +238,69 @@
33 (account_id,))
34 additional_unrec = cr.fetchone()[0]
35 context.update({'reconciled': reconciled, 'unreconciled': unreconciled + additional_unrec})
36+=======
37+ reconciled += len(line_ids)
38+ if not context.get('allow_write_off', False):
39+ move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context={})
40+ else:
41+ move_line_obj.reconcile(cr, uid, line_ids, 'auto', form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
42+
43+ # get the list of partners who have more than one unreconciled transaction
44+ cr.execute(
45+ "SELECT partner_id " \
46+ "FROM account_move_line " \
47+ "WHERE account_id=%s " \
48+ "AND reconcile_id IS NULL " \
49+ "AND state <> 'draft' " \
50+ "AND partner_id IS NOT NULL " \
51+ "GROUP BY partner_id " \
52+ "HAVING count(*)>1",
53+ (account_id,))
54+ partner_ids = [id for (id,) in cr.fetchall()]
55+ #filter?
56+ for partner_id in partner_ids:
57+ # get the list of unreconciled 'debit transactions' for this partner
58+ cr.execute(
59+ "SELECT id, debit " \
60+ "FROM account_move_line " \
61+ "WHERE account_id=%s " \
62+ "AND partner_id=%s " \
63+ "AND reconcile_id IS NULL " \
64+ "AND state <> 'draft' " \
65+ "AND debit > 0",
66+ (account_id, partner_id))
67+ debits = cr.fetchall()
68+
69+ # get the list of unreconciled 'credit transactions' for this partner
70+ cr.execute(
71+ "SELECT id, credit " \
72+ "FROM account_move_line " \
73+ "WHERE account_id=%s " \
74+ "AND partner_id=%s " \
75+ "AND reconcile_id IS NULL " \
76+ "AND state <> 'draft' " \
77+ "AND credit > 0",
78+ (account_id, partner_id))
79+ credits = cr.fetchall()
80+
81+ (rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form['writeoff_acc_id'], form['period_id'], form['journal_id'], context)
82+ reconciled += rec
83+ unreconciled += unrec
84+
85+ # add the number of transactions for partners who have only one
86+ # unreconciled transactions to the unreconciled count
87+ partner_filter = partner_ids and 'AND partner_id not in (%s)' % ','.join(map(str, filter(None, partner_ids))) or ''
88+ cr.execute(
89+ "SELECT count(*) " \
90+ "FROM account_move_line " \
91+ "WHERE account_id=%s " \
92+ "AND reconcile_id IS NULL " \
93+ "AND state <> 'draft' " + partner_filter,
94+ (account_id,))
95+ additional_unrec = cr.fetchone()[0]
96+ unreconciled = unreconciled + additional_unrec
97+ context.update({'reconciled': reconciled, 'unreconciled': unreconciled})
98+>>>>>>> MERGE-SOURCE
99 model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')])
100 resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
101 return {