diff --git a/CHANGELOG b/CHANGELOG index 44de11f380..01127ac2bd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Change sequence on Journal into Property for multi-company * Allow egg installation Version 1.0.0 - 2008-11-17 diff --git a/account.py b/account.py index 49553f7bc2..9715b6e30b 100644 --- a/account.py +++ b/account.py @@ -1042,6 +1042,7 @@ class GeneralLegder(Report): account_ids = account_obj.search(cursor, user, [ ('company', '=', datas['form']['company']), + ('kind', '!=', 'view'), ], order=[('code', 'ASC'), ('id', 'ASC')], context=context) start_period_ids = [0] @@ -1229,6 +1230,7 @@ class TrialBalance(Report): datas['form']['company'], context=context) account_ids = account_obj.search(cursor, user, [ + ('company', '=', datas['form']['company']), ('kind', '!=', 'view'), ], context=context) diff --git a/fiscalyear.py b/fiscalyear.py index adcb31e81f..c25304a21f 100644 --- a/fiscalyear.py +++ b/fiscalyear.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. 'Fiscal Year' from trytond.osv import fields, OSV @@ -28,7 +29,8 @@ class FiscalYear(OSV): post_move_sequence = fields.Many2One('ir.sequence', 'Post Move Sequence', required=True, domain="[('code', '=', 'account.move')," \ "['OR', ('company', '=', company)," \ - "('company', '=', False)]]") + "('company', '=', False)]]", + context="{'code': 'account.move', 'company': company}") company = fields.Many2One('company.company', 'Company', required=True) def __init__(self): diff --git a/journal.py b/journal.py index 7b1a3b2202..3bfdf6390d 100644 --- a/journal.py +++ b/journal.py @@ -1,8 +1,10 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Journal" from trytond.osv import fields, OSV from trytond.wizard import Wizard, WizardOSV +from trytond.sql_db import table_handler STATES = { 'readonly': "state == 'close'", @@ -81,9 +83,10 @@ class Journal(OSV): view = fields.Many2One('account.journal.view', 'View') centralised = fields.Boolean('Centralised counterpart') update_posted = fields.Boolean('Allow cancelling moves') - #TODO change sequence into Property - sequence = fields.Many2One('ir.sequence', 'Sequence', required=True, - domain="[('code', '=', 'account.journal')]") + sequence = fields.Property(type='many2one', relation='ir.sequence', + string='Sequence', required=True, + domain="[('code', '=', 'account.journal')]", + context={'code': 'account.journal'}) credit_account = fields.Property(type='many2one', relation='account.account', string='Default Credit Account', domain="[('kind', '!=', 'view'), ('company', '=', company)]", @@ -105,6 +108,21 @@ class Journal(OSV): super(Journal, self).__init__() self._order.insert(0, ('name', 'ASC')) + def _auto_init(self, cursor, module_name): + super(Journal, self)._auto_init(cursor, module_name) + table = table_handler(cursor, self._table, self._name, module_name) + + # Migration from 1.0 sequence Many2One change into Property + if 'sequence' in table.table: + property_obj = self.pool.get('ir.property') + cursor.execute('SELECT id, sequence FROM "' + self._table +'"') + for journal_id, sequence_id in cursor.fetchall(): + property_obj.set(cursor, 0, 'sequence', self._name, + journal_id, (sequence_id and \ + 'ir.sequence,' + str(sequence_id) or False)) + cursor.execute('ALTER TABLE "' + self._table +'" ' \ + 'DROP COLUMN sequence') + def default_active(self, cursor, user, context=None): return True diff --git a/period.py b/period.py index 4939847534..0fa153fcf5 100644 --- a/period.py +++ b/period.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. 'Period' from trytond.osv import fields, OSV @@ -27,7 +28,8 @@ class Period(OSV): ('close', 'Close'), ], 'State', readonly=True, required=True) post_move_sequence =fields.Many2One('ir.sequence', 'Post Move Sequence', - required=True, domain="[('code', '=', 'account.move')]") + required=True, domain="[('code', '=', 'account.move')]", + context="{'code': 'account.move'}") type = fields.Selection([ ('standard', 'Standard'), ('adjustment', 'Adjustment'),