From dfdad2735f1bbb868eed9b0964e52665afe5cd33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 12:44:53 +0100 Subject: [PATCH 1/5] Handle default value for sequence with context for issue609 --- fiscalyear.py | 6 ++++-- period.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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/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'), From fd501da4991d4a6be4d761d02357fae6e3e97327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 17:51:17 +0100 Subject: [PATCH 2/5] Filter account view in General Ledger for issue615 --- account.py | 1 + 1 file changed, 1 insertion(+) diff --git a/account.py b/account.py index 49553f7bc2..ae900b708f 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] From 4c0b73008482d4411b249732ec6beb55451255ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 17:51:46 +0100 Subject: [PATCH 3/5] Filter account on compye for Trial Balance --- account.py | 1 + 1 file changed, 1 insertion(+) diff --git a/account.py b/account.py index ae900b708f..9715b6e30b 100644 --- a/account.py +++ b/account.py @@ -1230,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) From 08a29a71e1f4599c149571e6a40a2ce0817dfcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 18:20:53 +0100 Subject: [PATCH 4/5] Change sequence on Journal into Property for multi-company --- CHANGELOG | 1 + journal.py | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) 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/journal.py b/journal.py index 7b1a3b2202..0403adfafa 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,19 @@ 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) + 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 From cf2b00cd8195a718d4fd39346d13952db2cbec0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Nov 2008 18:32:08 +0100 Subject: [PATCH 5/5] Add missing comment on migration --- journal.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/journal.py b/journal.py index 0403adfafa..3bfdf6390d 100644 --- a/journal.py +++ b/journal.py @@ -111,6 +111,8 @@ class Journal(OSV): 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 +'"')