Change sequence on Journal into Property for multi-company

This commit is contained in:
Cédric Krier
2008-11-25 18:20:53 +01:00
parent 4c0b730084
commit 08a29a71e1
2 changed files with 21 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
* Change sequence on Journal into Property for multi-company
* Allow egg installation
Version 1.0.0 - 2008-11-17
+20 -4
View File
@@ -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