Merge lp:~openerp-dev/openobject-addons/6.0-opw-4823-skh into lp:openobject-addons/6.0

Proposed by Riken Bhorania (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.0-opw-4823-skh
Merge into: lp:openobject-addons/6.0
Diff against target: 203 lines (+44/-21)
9 files modified
account/account.py (+3/-1)
account/account_move_line.py (+9/-5)
account/report/account_general_ledger.py (+3/-2)
account/report/account_partner_ledger.py (+6/-3)
account/wizard/account_report_common.py (+2/-2)
account/wizard/account_report_general_ledger.py (+2/-1)
account/wizard/account_report_general_ledger_view.xml (+4/-1)
account/wizard/account_report_partner_ledger.py (+11/-4)
account/wizard/account_report_partner_ledger_view.xml (+4/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.0-opw-4823-skh
Reviewer Review Type Date Requested Status
Priyesh (OpenERP) Pending
Jay Vora (Serpent Consulting Services) Pending
Somesh Khare Pending
Review via email: mp+68489@code.launchpad.net

This proposal supersedes a proposal from 2011-06-06.

Description of the change

Hello Sir,

[Fix] : Initial balance is simply doubling the amounts on sums(credit/debit/balance).

This branch have a fix for the Case: 4823. Where the Initial balance is simply doubling the amounts on the sum (credit/debit/balance). The improved logic is also applied to General Ledger also.

Thanks
skh, rch

To post a comment you must log in.
Revision history for this message
Priyesh (OpenERP) (pso-openerp) wrote : Posted in a previous version of this proposal

Hello Somesh,

Needs few changes:
1. No need to change the position of 'include initial balance' field
2. If I filter by Date and after that If I filter by Period, 'From Date' and 'To Date' fields should be empty.
3. Initial balance line in report is not coming with correct values with 'Period' in 'Filter By'.

Thanks,
Priyesh

review: Needs Fixing
Revision history for this message
Riken Bhorania (OpenERP) (rch-openerp) wrote : Posted in a previous version of this proposal

Hello Somesh,

Functionality works as per the requirement but need some changes to make it more relevant.

Change 'Filter By' field's value in following sequence.
a. 'Unreconciled Entries' then 'Fiscal Year' field's value is removed. Is Deletion really necessary?
b. 'Date'
c. 'Periods' then 'Start Date' and 'End Date' must be empty.

Thanks,
Riken

Revision history for this message
Somesh Khare (somesh.khare) wrote : Posted in a previous version of this proposal

Hello Sir,

[Fix] : Initial balance is simply doubling the amounts on sums(credit/debit/balance).

1. I have update the code for the periods when 'Periods' then 'Start Date' and 'End Date' must be empty.
2. For point "a. 'Unreconciled Entries' then 'Fiscal Year' field's value is removed. Is Deletion really necessary?".
   This field is set as False so that once user select "Unreconciled Entries" he should select the Fiscal year for which he wants to print the "Unreconciled Entries".

Please correct me if I am worng.

Thanks,
Somesh

review: Needs Resubmitting

Unmerged revisions

4653. By Riken Bhorania (OpenERP)

[IMP]: Improved General Ledger wizard to avoid selection confusion in the case of initial balance.

4652. By Riken Bhorania (OpenERP)

[Merge]: From lp:openobject-addons/6.0

4651. By Somesh Khare

[FIX] Account :Initial balance is simply doubling the amounts on sums (Ref : Case 4823)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2011-07-08 11:26:10 +0000
3+++ account/account.py 2011-07-20 05:23:33 +0000
4@@ -952,7 +952,9 @@
5 raise osv.except_osv(_('Error'), _('You should have chosen periods that belongs to the same company'))
6 if period_date_start > period_date_stop:
7 raise osv.except_osv(_('Error'), _('Start period should be smaller then End period'))
8- return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
9+ if period_from.special:
10+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id)])
11+ return self.search(cr, uid, [('date_start', '>=', period_date_start), ('date_stop', '<=', period_date_stop), ('company_id', '=', company1_id),('special', '=', False)])
12
13 account_period()
14
15
16=== modified file 'account/account_move_line.py'
17--- account/account_move_line.py 2011-06-22 20:05:58 +0000
18+++ account/account_move_line.py 2011-07-20 05:23:33 +0000
19@@ -82,16 +82,20 @@
20 period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1)
21 if period_ids and period_ids[0]:
22 first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context)
23- # Find the old periods where date start of those periods less then Start period
24- periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)])
25- periods = ','.join([str(x) for x in periods])
26- if periods:
27- query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND id IN (%s)) %s %s" % (fiscalyear_clause, periods, where_move_state, where_move_lines_by_date)
28+ ids = ','.join([str(x) for x in context['periods']])
29+ query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND date_start <= '%s' AND id NOT IN (%s)) %s %s" % (fiscalyear_clause, first_period.date_start, ids, where_move_state, where_move_lines_by_date)
30 else:
31 ids = ','.join([str(x) for x in context['periods']])
32 query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s) AND id IN (%s)) %s %s" % (fiscalyear_clause, ids, where_move_state, where_move_lines_by_date)
33 else:
34 query = obj+".state <> 'draft' AND "+obj+".period_id IN (SELECT id FROM account_period WHERE fiscalyear_id IN (%s)) %s %s" % (fiscalyear_clause, where_move_state, where_move_lines_by_date)
35+
36+ if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
37+ #we didn't pass any filter in the context, and the initial balance can't be computed using only the fiscalyear otherwise entries will be summed twice
38+ #so we have to invalidate this query
39+ raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance"))
40+
41+
42
43 if context.get('journal_ids', False):
44 query += ' AND '+obj+'.journal_id IN (%s)' % ','.join(map(str, context['journal_ids']))
45
46=== modified file 'account/report/account_general_ledger.py'
47--- account/report/account_general_ledger.py 2011-01-14 00:11:01 +0000
48+++ account/report/account_general_ledger.py 2011-07-20 05:23:33 +0000
49@@ -40,9 +40,10 @@
50 self.sortby = data['form'].get('sortby', 'sort_date')
51 self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context',{}))
52 ctx2 = data['form'].get('used_context',{}).copy()
53- ctx2.update({'initial_bal': True})
54+ self.init_balance = data['form'].get('initial_balance', True)
55+ if self.init_balance:
56+ ctx2.update({'initial_bal': True})
57 self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
58- self.init_balance = data['form']['initial_balance']
59 self.display_account = data['form']['display_account']
60 self.target_move = data['form'].get('target_move', 'all')
61 ctx = self.context.copy()
62
63=== modified file 'account/report/account_partner_ledger.py'
64--- account/report/account_partner_ledger.py 2011-01-14 00:11:01 +0000
65+++ account/report/account_partner_ledger.py 2011-07-20 05:23:33 +0000
66@@ -58,10 +58,13 @@
67 obj_partner = self.pool.get('res.partner')
68 self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
69 ctx2 = data['form'].get('used_context',{}).copy()
70- ctx2.update({'initial_bal': True})
71+ self.initial_balance = data['form'].get('initial_balance', True)
72+ if self.initial_balance:
73+ ctx2.update({'initial_bal': True})
74 self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
75- self.reconcil = data['form'].get('reconcil', True)
76- self.initial_balance = data['form'].get('initial_balance', True)
77+ self.reconcil = True
78+ if data['form']['filter'] == 'unreconciled':
79+ self.reconcil = False
80 self.result_selection = data['form'].get('result_selection', 'customer')
81 self.amount_currency = data['form'].get('amount_currency', False)
82 self.target_move = data['form'].get('target_move', 'all')
83
84=== modified file 'account/wizard/account_report_common.py'
85--- account/wizard/account_report_common.py 2011-01-14 00:11:01 +0000
86+++ account/wizard/account_report_common.py 2011-07-20 05:23:33 +0000
87@@ -56,7 +56,7 @@
88 return res
89
90 def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
91- res = {}
92+ res = {'value': {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}}
93 if filter == 'filter_no':
94 res['value'] = {'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False}
95 if filter == 'filter_date':
96@@ -68,7 +68,7 @@
97 FROM account_period p
98 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
99 WHERE f.id = %s
100- ORDER BY p.date_start ASC
101+ ORDER BY p.date_start ASC, p.special ASC
102 LIMIT 1) AS period_start
103 UNION
104 SELECT * FROM (SELECT p.id
105
106=== modified file 'account/wizard/account_report_general_ledger.py'
107--- account/wizard/account_report_general_ledger.py 2011-01-14 00:11:01 +0000
108+++ account/wizard/account_report_general_ledger.py 2011-07-20 05:23:33 +0000
109@@ -32,6 +32,7 @@
110 help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
111 'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"),
112 'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort By', required=True),
113+ 'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods')], "Filter by", required=True)
114 }
115 _defaults = {
116 'landscape': True,
117@@ -50,7 +51,7 @@
118 if context is None:
119 context = {}
120 data = self.pre_print_report(cr, uid, ids, data, context=context)
121- data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby'])[0])
122+ data['form'].update(self.read(cr, uid, ids, ['landscape', 'initial_balance', 'amount_currency', 'sortby','filter'])[0])
123 if not data['form']['fiscalyear_id']:# GTK client problem onchange does not consider in save record
124 data['form'].update({'initial_balance': False})
125 if data['form']['landscape']:
126
127=== modified file 'account/wizard/account_report_general_ledger_view.xml'
128--- account/wizard/account_report_general_ledger_view.xml 2011-01-14 00:11:01 +0000
129+++ account/wizard/account_report_general_ledger_view.xml 2011-07-20 05:23:33 +0000
130@@ -17,10 +17,13 @@
131 <field name="display_account"/>
132 <field name="sortby"/>
133 <field name="landscape"/>
134- <field name="initial_balance" attrs="{'readonly':[('fiscalyear_id','=', False)]}"/>
135 <field name="amount_currency"/>
136 <newline/>
137 </xpath>
138+ <xpath expr="//field[@name='filter']" position="replace">
139+ <field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4"/>
140+ <field name="initial_balance" attrs="{'readonly':['|',('fiscalyear_id','=', False), ('filter', 'in', ('filter_no'))]}"/>
141+ </xpath>
142 </data>
143 </field>
144 </record>
145
146=== modified file 'account/wizard/account_report_partner_ledger.py'
147--- account/wizard/account_report_partner_ledger.py 2011-01-14 00:11:01 +0000
148+++ account/wizard/account_report_partner_ledger.py 2011-07-20 05:23:33 +0000
149@@ -32,22 +32,29 @@
150 _columns = {
151 'initial_balance': fields.boolean('Include initial balances',
152 help='It adds initial balance row on report which display previous sum amount of debit/credit/balance'),
153- 'reconcil': fields.boolean('Include Reconciled Entries', help='Consider reconciled entries'),
154+ 'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods'), ('unreconciled', 'Unreconciled Entries')], "Filter by", required=True),
155 'page_split': fields.boolean('One Partner Per Page', help='Display Ledger Report with One partner per page'),
156 'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"),
157
158 }
159 _defaults = {
160- 'reconcil': True,
161- 'initial_balance': True,
162+ 'initial_balance': False,
163 'page_split': False,
164 }
165
166+ def onchange_filter(self, cr, uid, ids, filter='filter_no', fiscalyear_id=False, context=None):
167+ res = super(account_partner_ledger, self).onchange_filter(cr, uid, ids, filter=filter, fiscalyear_id=fiscalyear_id, context=context)
168+ if filter in ['filter_no', 'unreconciled']:
169+ if filter == 'unreconciled':
170+ res['value'].update({'fiscalyear_id': False})
171+ res['value'].update({'initial_balance': False, 'period_from': False, 'period_to': False, 'date_from': False ,'date_to': False})
172+ return res
173+
174 def _print_report(self, cr, uid, ids, data, context=None):
175 if context is None:
176 context = {}
177 data = self.pre_print_report(cr, uid, ids, data, context=context)
178- data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'reconcil', 'page_split', 'amount_currency'])[0])
179+ data['form'].update(self.read(cr, uid, ids, ['initial_balance', 'filter', 'page_split', 'amount_currency'])[0])
180 if data['form']['page_split']:
181 return {
182 'type': 'ir.actions.report.xml',
183
184=== modified file 'account/wizard/account_report_partner_ledger_view.xml'
185--- account/wizard/account_report_partner_ledger_view.xml 2011-01-14 00:11:01 +0000
186+++ account/wizard/account_report_partner_ledger_view.xml 2011-07-20 05:23:33 +0000
187@@ -15,12 +15,14 @@
188 </xpath>
189 <xpath expr="//field[@name='target_move']" position="after">
190 <field name="result_selection"/>
191- <field name="initial_balance"/>
192- <field name="reconcil"/>
193 <field name="amount_currency"/>
194 <field name="page_split"/>
195 <newline/>
196 </xpath>
197+ <xpath expr="//field[@name='filter']" position="replace">
198+ <field name="filter" on_change="onchange_filter(filter, fiscalyear_id)" colspan="4"/>
199+ <field name="initial_balance" attrs="{'readonly':[('filter', 'in', ('filter_no', 'unreconciled'))]}" />
200+ </xpath>
201 </data>
202 </field>
203 </record>