Merge lp:~openerp-dev/openobject-addons/trunk-bug-913494-psi into lp:openobject-addons

Proposed by Purnendu Singh (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-913494-psi
Merge into: lp:openobject-addons
Diff against target: 115 lines (+23/-15)
1 file modified
account/wizard/account_automatic_reconcile.py (+23/-15)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-913494-psi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+92725@code.launchpad.net

Description of the change

To post a comment you must log in.
6553. By Purnendu Singh (OpenERP)

[IMP] account: used between to get data between given days

Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Hello Purenendu,

Thanks for the implementation of that feature. We can keep this in pending for future release.

Thanks,
Mustufa

Unmerged revisions

6553. By Purnendu Singh (OpenERP)

[IMP] account: used between to get data between given days

6552. By invitu

[FIX] account: automatice reconcilation doesn't use start/end date

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 2011-12-31 07:14:16 +0000
3+++ account/wizard/account_automatic_reconcile.py 2012-02-13 12:28:20 +0000
4@@ -130,7 +130,7 @@
5 while credits and debits and ok:
6 res = check5(credits, debits, power)
7 if res:
8- move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context)
9+ move_line_obj.reconcile(cr, uid, res[0] + res[1], 'auto', writeoff_acc_id, period_id, journal_id, context=context)
10 reconciled += len(res[0]) + len(res[1])
11 credits = [(id, credit) for (id, credit) in credits if id not in res[0]]
12 debits = [(id, debit) for (id, debit) in debits if id not in res[1]]
13@@ -146,6 +146,8 @@
14 form = self.browse(cr, uid, ids, context=context)[0]
15 max_amount = form.max_amount or 0.0
16 power = form.power
17+ date_start = form.date1
18+ date_end = form.date2
19 allow_write_off = form.allow_write_off
20 reconciled = unreconciled = 0
21 if not form.account_ids:
22@@ -154,13 +156,14 @@
23 params = (account_id.id,)
24 if not allow_write_off:
25 query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL
26- AND state <> 'draft' GROUP BY partner_id
27+ AND state <> 'draft' AND date BETWEEN %s AND %s GROUP BY partner_id
28 HAVING ABS(SUM(debit-credit)) = 0.0 AND count(*)>0"""
29+ params += (date_start, date_end,)
30 else:
31 query = """SELECT partner_id FROM account_move_line WHERE account_id=%s AND reconcile_id IS NULL
32- AND state <> 'draft' GROUP BY partner_id
33+ AND state <> 'draft' AND date BETWEEN %s AND %s GROUP BY partner_id
34 HAVING ABS(SUM(debit-credit)) < %s AND count(*)>0"""
35- params += (max_amount,)
36+ params += (date_start, date_end, max_amount,)
37 # reconcile automatically all transactions from partners whose balance is 0
38 cr.execute(query, params)
39 partner_ids = [id for (id,) in cr.fetchall()]
40@@ -171,13 +174,14 @@
41 "WHERE account_id=%s " \
42 "AND partner_id=%s " \
43 "AND state <> 'draft' " \
44- "AND reconcile_id IS NULL",
45- (account_id.id, partner_id))
46+ "AND reconcile_id IS NULL "\
47+ "AND date BETWEEN %s AND %s",
48+ (account_id.id, partner_id, date_start, date_end,))
49 line_ids = [id for (id,) in cr.fetchall()]
50 if line_ids:
51 reconciled += len(line_ids)
52 if allow_write_off:
53- move_line_obj.reconcile(cr, uid, line_ids, 'auto', form.writeoff_acc_id.id, form.period_id.id, form.journal_id.id, context)
54+ move_line_obj.reconcile(cr, uid, line_ids, 'auto', form.writeoff_acc_id.id, form.period_id.id, form.journal_id.id, context=context)
55 else:
56 move_line_obj.reconcile_partial(cr, uid, line_ids, 'manual', context=context)
57
58@@ -188,10 +192,11 @@
59 "WHERE account_id=%s " \
60 "AND reconcile_id IS NULL " \
61 "AND state <> 'draft' " \
62- "AND partner_id IS NOT NULL " \
63+ "AND partner_id IS NOT NULL "\
64+ "AND date BETWEEN %s AND %s " \
65 "GROUP BY partner_id " \
66 "HAVING count(*)>1",
67- (account_id.id,))
68+ (account_id.id, date_start, date_end,))
69 partner_ids = [id for (id,) in cr.fetchall()]
70 #filter?
71 for partner_id in partner_ids:
72@@ -204,8 +209,9 @@
73 "AND reconcile_id IS NULL " \
74 "AND state <> 'draft' " \
75 "AND debit > 0 " \
76+ "AND date BETWEEN %s AND %s " \
77 "ORDER BY date_maturity",
78- (account_id.id, partner_id))
79+ (account_id.id, partner_id, date_start, date_end))
80 debits = cr.fetchall()
81
82 # get the list of unreconciled 'credit transactions' for this partner
83@@ -217,11 +223,12 @@
84 "AND reconcile_id IS NULL " \
85 "AND state <> 'draft' " \
86 "AND credit > 0 " \
87+ "AND date BETWEEN %s AND %s "\
88 "ORDER BY date_maturity",
89- (account_id.id, partner_id))
90+ (account_id.id, partner_id, date_start, date_end))
91 credits = cr.fetchall()
92
93- (rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form.writeoff_acc_id.id, form.period_id.id, form.journal_id.id, context)
94+ (rec, unrec) = self.do_reconcile(cr, uid, credits, debits, max_amount, power, form.writeoff_acc_id.id, form.period_id.id, form.journal_id.id, context=context)
95 reconciled += rec
96 unreconciled += unrec
97
98@@ -233,13 +240,14 @@
99 "FROM account_move_line " \
100 "WHERE account_id=%s " \
101 "AND reconcile_id IS NULL " \
102+ "AND date BETWEEN %s AND %s "\
103 "AND state <> 'draft' " + partner_filter,
104- (account_id.id,))
105+ (account_id.id, date_start, date_end,))
106 additional_unrec = cr.fetchone()[0]
107 unreconciled = unreconciled + additional_unrec
108 context.update({'reconciled': reconciled, 'unreconciled': unreconciled})
109- model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')])
110- resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'])[0]['res_id']
111+ model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','account_automatic_reconcile_view1')], context=context)
112+ resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
113 return {
114 'view_type': 'form',
115 'view_mode': 'form',

Subscribers

People subscribed via source and target branches

to all changes: