Ravi Gohil (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.0-opw-575542-rgo into
lp:openobject-addons/6.0.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Related bugs:
Bug #931022 in OpenERP Addons: "[6.0.3]Initial Balance numbers do not make
sense and are added to account balances"
https://bugs.launchpad.net/openobject-addons/+bug/931022
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-575542-rgo/+merge/109281
Hello,
When you print the `Partner Ledger` report with `Include Initial Balances`
ticked and `No Filter` or `Period` option selected in `Filter By` field of the
wizard, amount of `Initial Balance` in .pdf report is displayed incorrect.
This MP contains fix for this issue and also contains similar improvements for
`General Ledger` report.
Kindly review the fix.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-575542-rgo/+merge/109281
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.0-opw-575542-rgo.
=== modified file 'account/account_move_line.py'
--- account/account_move_line.py 2012-03-06 12:36:12 +0000
+++ account/account_move_line.py 2012-06-08 05:58:08 +0000
@@ -82,16 +82,17 @@
period_ids = fiscalperiod_obj.search(cr, uid, [('id', 'in', context['periods'])], order='date_start', limit=1)
if period_ids and period_ids[0]:
first_period = fiscalperiod_obj.browse(cr, uid, period_ids[0], context=context)
- # Find the old periods where date start of those periods less then Start period
- periods = fiscalperiod_obj.search(cr, uid, [('date_start', '<', first_period.date_start)])
- periods = ','.join([str(x) for x in periods])
- if periods:
- 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)
+ ids = ','.join([str(x) for x in context['periods']])
+ 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)
else:
ids = ','.join([str(x) for x in context['periods']])
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)
else:
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)
+ if initial_bal and not context.get('periods', False) and not where_move_lines_by_date:
+ #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
+ #so we have to invalidate this query
+ raise osv.except_osv(_('Warning !'),_("You haven't supplied enough argument to compute the initial balance"))
if context.get('journal_ids', False):
query += ' AND '+obj+'.journal_id IN (%s)' % ','.join(map(str, context['journal_ids']))
=== modified file 'account/report/account_general_ledger.py'
--- account/report/account_general_ledger.py 2012-02-20 10:35:21 +0000
+++ account/report/account_general_ledger.py 2012-06-08 05:58:08 +0000
@@ -40,9 +40,10 @@
self.sortby = data['form'].get('sortby', 'sort_date')
self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context',{}))
ctx2 = data['form'].get('used_context',{}).copy()
- ctx2.update({'initial_bal': True})
+ self.init_balance = data['form']['initial_balance']
+ if self.init_balance:
+ ctx2.update({'initial_bal': True})
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
- self.init_balance = data['form']['initial_balance']
self.display_account = data['form']['display_account']
self.target_move = data['form'].get('target_move', 'all')
ctx = self.context.copy()
=== modified file 'account/report/account_partner_ledger.py'
--- account/report/account_partner_ledger.py 2011-09-07 07:07:17 +0000
+++ account/report/account_partner_ledger.py 2012-06-08 05:58:08 +0000
@@ -58,10 +58,11 @@
obj_partner = self.pool.get('res.partner')
self.query = obj_move._query_get(self.cr, self.uid, obj='l', context=data['form'].get('used_context', {}))
ctx2 = data['form'].get('used_context',{}).copy()
- ctx2.update({'initial_bal': True})
+ self.initial_balance = data['form']['initial_balance']
+ if self.initial_balance:
+ ctx2.update({'initial_bal': True})
self.init_query = obj_move._query_get(self.cr, self.uid, obj='l', context=ctx2)
self.reconcil = data['form'].get('reconcil', True)
- self.initial_balance = data['form'].get('initial_balance', True)
self.result_selection = data['form'].get('result_selection', 'customer')
self.amount_currency = data['form'].get('amount_currency', False)
self.target_move = data['form'].get('target_move', 'all')
=== modified file 'account/wizard/account_report_general_ledger_view.xml'
--- account/wizard/account_report_general_ledger_view.xml 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_general_ledger_view.xml 2012-06-08 05:58:08 +0000
@@ -17,7 +17,7 @@
<field name="display_account"/>
<field name="sortby"/>
<field name="landscape"/>
- <field name="initial_balance" attrs="{'readonly':[('fiscalyear_id','=', False)]}"/>
+ <field name="initial_balance" attrs="{'readonly':['|', ('fiscalyear_id','=', False), ('filter', '=', 'filter_no')]}"/>
<field name="amount_currency"/>
<newline/>
</xpath>
=== modified file 'account/wizard/account_report_partner_ledger.py'
--- account/wizard/account_report_partner_ledger.py 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_partner_ledger.py 2012-06-08 05:58:08 +0000
@@ -39,7 +39,7 @@
}
_defaults = {
'reconcil': True,
- 'initial_balance': True,
+ 'initial_balance': False,
'page_split': False,
}
=== modified file 'account/wizard/account_report_partner_ledger_view.xml'
--- account/wizard/account_report_partner_ledger_view.xml 2011-01-14 00:11:01 +0000
+++ account/wizard/account_report_partner_ledger_view.xml 2012-06-08 05:58:08 +0000
@@ -15,7 +15,7 @@
</xpath>
<xpath expr="//field[@name='target_move']" position="after">
<field name="result_selection"/>
- <field name="initial_balance"/>
+ <field name="initial_balance" attrs="{'readonly':[('filter', '=', 'filter_no')]}"/>
<field name="reconcil"/>
<field name="amount_currency"/>
<field name="page_split"/>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp