[FIX] bugfixed the closing of fiscal year: we are now passing the entries reconciled on another fiscal year as it should be (if the account type has defferal method =
unreconciled) [FIX] minors bugfixes in fiscal year closing: given period wasn't used, reconciliation have to be made on unreconciliable accounts lp bug: https://launchpad.net/bugs/317649 fixed bzr revid: qdp@tinyerp.com-20090130150357-vr6lu4ukjt5jd0hc
This commit is contained in:
parent
89e5473075
commit
a9d7005af9
|
@ -559,12 +559,12 @@ class account_move_line(osv.osv):
|
|||
GROUP BY account_id,reconcile_id')
|
||||
r = cr.fetchall()
|
||||
#TODO: move this check to a constraint in the account_move_reconcile object
|
||||
if (len(r) != 1) and context.get('same_account', True):
|
||||
if (len(r) != 1) and not context.get('fy_closing', False):
|
||||
raise osv.except_osv(_('Error'), _('Entries are not of the same account or already reconciled ! '))
|
||||
if not unrec_lines:
|
||||
raise osv.except_osv(_('Error'), _('Entry is already reconciled'))
|
||||
account = self.pool.get('account.account').browse(cr, uid, account_id, context=context)
|
||||
if not account.reconcile:
|
||||
if not context.get('fy_closing', False) and not account.reconcile:
|
||||
raise osv.except_osv(_('Error'), _('The account is not defined to be reconcile !'))
|
||||
if r[0][1] != None:
|
||||
raise osv.except_osv(_('Error'), _('Some entries are already reconciled !'))
|
||||
|
|
|
@ -56,13 +56,13 @@ def _data_save(self, cr, uid, data, context):
|
|||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
fy_id = data['form']['fy_id']
|
||||
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'])
|
||||
period_ids = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', fy_id)])
|
||||
fy_period_set = ','.join(map(str, period_ids))
|
||||
periods_fy2 = pool.get('account.period').search(cr, uid, [('fiscalyear_id', '=', data['form']['fy2_id'])])
|
||||
fy2_period_set = ','.join(map(str, periods_fy2))
|
||||
|
||||
periods_fy2 = new_fyear.period_ids
|
||||
if not periods_fy2:
|
||||
raise wizard.except_wizard(_('UserError'),
|
||||
_('There are no periods defined on New Fiscal Year.'))
|
||||
period=periods_fy2[0]
|
||||
period = pool.get('account.period').browse(cr, uid, data['form']['period_id'], context=context)
|
||||
new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id'], context=context)
|
||||
|
||||
new_journal = data['form']['journal_id']
|
||||
new_journal = pool.get('account.journal').browse(cr, uid, new_journal, context=context)
|
||||
|
@ -87,6 +87,7 @@ def _data_save(self, cr, uid, data, context):
|
|||
ids = map(lambda x: x[0], cr.fetchall())
|
||||
for account in pool.get('account.account').browse(cr, uid, ids,
|
||||
context={'fiscalyear': fy_id}):
|
||||
|
||||
accnt_type_data = account.user_type
|
||||
if not accnt_type_data:
|
||||
continue
|
||||
|
@ -120,7 +121,40 @@ def _data_save(self, cr, uid, data, context):
|
|||
if not result:
|
||||
break
|
||||
for move in result:
|
||||
parent_id = move['id']
|
||||
move.pop('id')
|
||||
move.update({
|
||||
'date': period.date_start,
|
||||
'journal_id': new_journal.id,
|
||||
'period_id': period.id,
|
||||
})
|
||||
pool.get('account.move.line').create(cr, uid, move, {
|
||||
'journal_id': new_journal.id,
|
||||
'period_id': period.id,
|
||||
})
|
||||
offset += limit
|
||||
|
||||
#We have also to consider all move_lines that were reconciled
|
||||
#on another fiscal year, and report them too
|
||||
offset = 0
|
||||
limit = 100
|
||||
while True:
|
||||
#TODO: this query could be improved in order to work if there is more than 2 open FY
|
||||
# a.period_id IN ('+fy2_period_set+') is the problematic clause
|
||||
cr.execute('SELECT b.id, b.name, b.quantity, b.debit, b.credit, b.account_id, b.ref, ' \
|
||||
'b.amount_currency, b.currency_id, b.blocked, b.partner_id, ' \
|
||||
'b.date_maturity, b.date_created ' \
|
||||
'FROM account_move_line a, account_move_line b ' \
|
||||
'WHERE b.account_id = %s ' \
|
||||
'AND b.reconcile_id is NOT NULL ' \
|
||||
'AND a.reconcile_id = b.reconcile_id ' \
|
||||
'AND b.period_id IN ('+fy_period_set+') ' \
|
||||
'AND a.period_id IN ('+fy2_period_set+') ' \
|
||||
'ORDER BY id ' \
|
||||
'LIMIT %s OFFSET %s', (account.id, limit, offset))
|
||||
result = cr.dictfetchall()
|
||||
if not result:
|
||||
break
|
||||
for move in result:
|
||||
move.pop('id')
|
||||
move.update({
|
||||
'date': period.date_start,
|
||||
|
@ -148,7 +182,6 @@ def _data_save(self, cr, uid, data, context):
|
|||
if not result:
|
||||
break
|
||||
for move in result:
|
||||
parent_id = move['id']
|
||||
move.pop('id')
|
||||
move.update({
|
||||
'date': period.date_start,
|
||||
|
@ -160,10 +193,8 @@ def _data_save(self, cr, uid, data, context):
|
|||
|
||||
ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id),
|
||||
('period_id.fiscalyear_id','=',new_fyear.id)])
|
||||
|
||||
context['same_account'] = False
|
||||
context['fy_closing'] = True
|
||||
pool.get('account.move.line').reconcile(cr, uid, ids, context=context)
|
||||
|
||||
new_period = data['form']['period_id']
|
||||
ids = pool.get('account.journal.period').search(cr, uid, [('journal_id','=',new_journal.id),('period_id','=',new_period)])
|
||||
if ids:
|
||||
|
|
Loading…
Reference in New Issue