diff --git a/addons/account/account.py b/addons/account/account.py index 46a15a4f91f..ecf346d2592 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -560,8 +560,8 @@ class account_period(osv.osv): _columns = { 'name': fields.char('Period Name', size=64, required=True), 'code': fields.char('Code', size=12), - 'special': fields.boolean('Special Period', size=12, - help="Special periods are periods that can overlap, like the 13rd period in fiscal years for closing entries."), + 'special': fields.boolean('Opening/Closing Period', size=12, + help="These periods can overlap."), 'date_start': fields.date('Start of period', required=True, states={'done':[('readonly',True)]}), 'date_stop': fields.date('End of period', required=True, states={'done':[('readonly',True)]}), 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True, states={'done':[('readonly',True)]}, select=True), diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 7c0f69411cd..2e2a6913882 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -367,8 +367,7 @@ 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 Reconciliation') + } def _get_date(self, cr, uid, context): @@ -537,11 +536,7 @@ 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) @@ -640,10 +635,6 @@ class account_move_line(osv.osv): '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) for id in ids: diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml index f470eb60dd3..5c5e2df1e82 100644 --- a/addons/account/account_view.xml +++ b/addons/account/account_view.xml @@ -741,10 +741,6 @@ - - - - @@ -784,7 +780,6 @@ - diff --git a/addons/account/account_wizard.xml b/addons/account/account_wizard.xml index 73f87846c57..b90e663712d 100644 --- a/addons/account/account_wizard.xml +++ b/addons/account/account_wizard.xml @@ -7,16 +7,17 @@ - - + - - + + + + - + diff --git a/addons/account/wizard/wizard_fiscalyear_close.py b/addons/account/wizard/wizard_fiscalyear_close.py index c60604bd0dd..8af3ed8a353 100644 --- a/addons/account/wizard/wizard_fiscalyear_close.py +++ b/addons/account/wizard/wizard_fiscalyear_close.py @@ -73,6 +73,13 @@ def _data_save(self, cr, uid, data, context): raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) + move_ids = pool.get('account.move.line').search(cr, uid, [ + ('journal_id','=',new_journal.id),('period_id.fiscalyear_id','=',new_fyear.id)]) + if move_ids: + raise wizard.except_wizard(_('UserError'), + _('The opening journal must not have any entry in the new fiscal year !')) + + query_line = pool.get('account.move.line')._query_get(cr, uid, obj='account_move_line', context={'fiscalyear': fy_id}) cr.execute('select id from account_account WHERE active') @@ -118,7 +125,6 @@ def _data_save(self, cr, uid, data, context): '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, @@ -147,11 +153,15 @@ def _data_save(self, cr, uid, data, context): '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 + ids = pool.get('account.move.line').search(cr, uid, [('journal_id','=',new_journal.id), + ('period_id.fiscalyear_id','=',new_fyear.id)]) + + pool.get('account.move.line').reconcile(cr, uid, ids, context=context) + new_fyear = pool.get('account.fiscalyear').browse(cr, uid, data['form']['fy2_id']) start_jp = new_fyear.start_journal_period_id cr.execute('UPDATE account_fiscalyear ' \ diff --git a/addons/account/wizard/wizard_fiscalyear_close_state.py b/addons/account/wizard/wizard_fiscalyear_close_state.py index c3cb5085947..52aa9f50477 100644 --- a/addons/account/wizard/wizard_fiscalyear_close_state.py +++ b/addons/account/wizard/wizard_fiscalyear_close_state.py @@ -28,7 +28,7 @@ from tools.translate import _ _transaction_form = '''
- + ''' diff --git a/addons/account/wizard/wizard_open_closed_fiscalyear.py b/addons/account/wizard/wizard_open_closed_fiscalyear.py index 677d114b055..05e29cf24b4 100644 --- a/addons/account/wizard/wizard_open_closed_fiscalyear.py +++ b/addons/account/wizard/wizard_open_closed_fiscalyear.py @@ -41,19 +41,18 @@ def _remove_entries(self, cr, uid, data, context): if not data_fyear.end_journal_period_id: raise wizard.except_wizard(_('Error'), _('No journal for ending writings have been defined for the fiscal year')) period_journal = data_fyear.end_journal_period_id - if not period_journal.journal_id.centralisation: - raise wizard.except_wizard(_('UserError'), _('The journal must have centralised counterpart')) ids_move = pool.get('account.move').search(cr,uid,[('journal_id','=',period_journal.journal_id.id),('period_id','=',period_journal.period_id.id)]) - pool.get('account.move').unlink(cr,uid,ids_move) - cr.execute('UPDATE account_journal_period ' \ - 'SET state = %s ' \ - 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', - ('draft',data_fyear)) - cr.execute('UPDATE account_period SET state = %s ' \ - 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) - cr.execute('UPDATE account_fiscalyear ' \ - 'SET state = %s, end_journal_period_id = null '\ - 'WHERE id = %s', ('draft',data_fyear)) + if ids_move: + cr.execute('delete from account_move where id in ('+','.join(map(str,ids_move))+')') + #cr.execute('UPDATE account_journal_period ' \ + # 'SET state = %s ' \ + # 'WHERE period_id IN (SELECT id FROM account_period WHERE fiscalyear_id = %s)', + # ('draft',data_fyear)) + #cr.execute('UPDATE account_period SET state = %s ' \ + # 'WHERE fiscalyear_id = %s', ('draft',data_fyear)) + #cr.execute('UPDATE account_fiscalyear ' \ + # 'SET state = %s, end_journal_period_id = null '\ + # 'WHERE id = %s', ('draft',data_fyear)) return {} class open_closed_fiscal(wizard.interface):