From 79e22ccc72933e4f8bc7ab7fb1cb3446422172ab Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 25 Sep 2008 15:28:52 +0530 Subject: [PATCH] solve problem : - if you make invoice in 2008 fiscal year and then close that year..and create new fiscal year and in new fiscal year you pay that invoice that time..original invoice entries does not get paid and reconciled... bzr revid: mra@tinyerp.com-20080925095852-fh177c0td425yx49 --- addons/account/account_move_line.py | 12 +++++++++++- addons/account/account_view.xml | 14 +++++++++----- addons/account/wizard/wizard_fiscalyear_close.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e55b6d54fee..abade8c579c 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -305,6 +305,8 @@ class account_move_line(osv.osv): 'analytic_account_id' : fields.many2one('account.analytic.account', 'Analytic Account'), #TODO: remove this 'amount_taxed':fields.float("Taxed Amount",digits=(16,2)), + 'parent_move_lines':fields.many2many('account.move.line', 'account_move_line_rel', 'child_id', 'parent_id', 'Parent'), + 'reconcile_implicit':fields.boolean('Implicit Reconciliaiton') } def _get_date(self, cr, uid, context): @@ -435,7 +437,11 @@ class account_move_line(osv.osv): currency = 0.0 account_id = False partner_id = False + implicit_lines = [] for line in unrec_lines: + if line.parent_move_lines: + for i in line.parent_move_lines: + implicit_lines.append(i.id) if line.state <> 'valid': raise osv.except_osv(_('Error'), _('Entry "%s" is not valid !') % line.name) @@ -531,9 +537,13 @@ class account_move_line(osv.osv): 'line_id': map(lambda x: (4,x,False), ids), 'line_partial_ids': map(lambda x: (3,x,False), ids) }) + wf_service = netsvc.LocalService("workflow") + if implicit_lines: + self.write(cr, uid, implicit_lines, {'reconcile_implicit':True,'reconcile_id':r_id}) + for id in implicit_lines: + wf_service.trg_trigger(uid, 'account.move.line', id, cr) # the id of the move.reconcile is written in the move.line (self) by the create method above # because of the way the line_id are defined: (4, x, False) - wf_service = netsvc.LocalService("workflow") for id in ids: wf_service.trg_trigger(uid, 'account.move.line', id, cr) return r_id diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index 62cb55b13e4..35d51003902 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -705,6 +705,10 @@ + + + + @@ -1354,10 +1358,10 @@ form form new - - + + + - @@ -1367,8 +1371,8 @@ Define Fiscal Years and Select Charts of Account open - - + + diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index 455ab049649..e26410e1dae 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -110,7 +110,7 @@ def _data_save(self, cr, uid, data, context): offset = 0 limit = 100 while True: - cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \ + cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ @@ -123,10 +123,13 @@ 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, + 'parent_move_lines':[(6,0,[parent_id])] }) pool.get('account.move.line').create(cr, uid, move, { 'journal_id': new_journal.id, @@ -137,7 +140,7 @@ def _data_save(self, cr, uid, data, context): offset = 0 limit = 100 while True: - cr.execute('SELECT name, quantity, debit, credit, account_id, ref, ' \ + cr.execute('SELECT id, name, quantity, debit, credit, account_id, ref, ' \ 'amount_currency, currency_id, blocked, partner_id, ' \ 'date_maturity, date_created ' \ 'FROM account_move_line ' \ @@ -149,10 +152,13 @@ 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, + 'parent_move_lines':[(6,0,[parent_id])] }) pool.get('account.move.line').create(cr, uid, move) offset += limit