From 94aeae9901b41bf60db6b1ae37e8fc02cbb2786f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 2 Feb 2009 13:09:08 +0100 Subject: [PATCH] Fix for new modeldb --- account.py | 23 ++++++++++++++--------- journal.py | 4 ++-- move.py | 11 ++++++----- tax.py | 2 +- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/account.py b/account.py index 459941a3e6..148778eae0 100644 --- a/account.py +++ b/account.py @@ -3,7 +3,6 @@ "Account" from trytond.osv import fields, OSV -from trytond.osv.orm import exclude from trytond.wizard import Wizard, WizardOSV from trytond.report import Report from decimal import Decimal @@ -336,7 +335,7 @@ class AccountTemplate(OSV): ids = [ids] return [(r['id'], r['code'] and r['code'] + ' - ' + unicode(r[self._rec_name]) \ or unicode(r[self._rec_name])) for r in self.read(cursor, user, ids, - [self._rec_name, 'code'], context=context, load='_classic_write')] + [self._rec_name, 'code'], context=context)] def _get_account_value(self, cursor, user, template, context=None): @@ -832,7 +831,7 @@ class Account(OSV): ids = [ids] return [(r['id'], r['code'] and r['code'] + ' - ' + unicode(r[self._rec_name]) \ or unicode(r[self._rec_name])) for r in self.read(cursor, user, ids, - [self._rec_name, 'code'], context=context, load='_classic_write')] + [self._rec_name, 'code'], context=context)] def copy(self, cursor, user, ids, default=None, context=None): res = super(Account, self).copy(cursor, user, ids, default=default, @@ -1116,14 +1115,16 @@ class GeneralLegder(Report): ('fiscalyear', '=', datas['form']['fiscalyear']), ('end_date', '<=', end_period.start_date), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + set(start_period_ids))) if datas['form']['end_period'] not in end_period_ids: end_period_ids.append(datas['form']['end_period']) else: end_period_ids = period_obj.search(cursor, user, [ ('fiscalyear', '=', datas['form']['fiscalyear']), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + set(start_period_ids))) end_context = context.copy() end_context['fiscalyear'] = datas['form']['fiscalyear'] @@ -1318,14 +1319,16 @@ class TrialBalance(Report): ('fiscalyear', '=', datas['form']['fiscalyear']), ('end_date', '<=', end_period.start_date), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + set(start_period_ids))) if datas['form']['end_period'] not in end_period_ids: end_period_ids.append(datas['form']['end_period']) else: end_period_ids = period_obj.search(cursor, user, [ ('fiscalyear', '=', datas['form']['fiscalyear']), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + set(start_period_ids))) ctx = context.copy() ctx['fiscalyear'] = datas['form']['fiscalyear'] @@ -1553,14 +1556,16 @@ class OpenIncomeStatement(Wizard): ('fiscalyear', '=', datas['form']['fiscalyear']), ('end_date', '<=', end_period.start_date), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + ste(start_period_ids))) if datas['form']['end_period'] not in end_period_ids: end_period_ids.append(datas['form']['end_period']) else: end_period_ids = period_obj.search(cursor, user, [ ('fiscalyear', '=', datas['form']['fiscalyear']), ], context=context) - end_period_ids = exclude(end_period_ids, start_period_ids) + end_period_ids = list(set(end_period_ids).difference( + set(start_period_ids))) model_data_ids = model_data_obj.search(cursor, user, [ ('fs_id', '=', 'act_account_income_statement_tree'), diff --git a/journal.py b/journal.py index cedcf3f1b6..2146f1359a 100644 --- a/journal.py +++ b/journal.py @@ -110,8 +110,8 @@ 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) + def init(self, cursor, module_name): + super(Journal, self).init(cursor, module_name) table = table_handler(cursor, self._table, self._name, module_name) # Migration from 1.0 sequence Many2One change into Property diff --git a/move.py b/move.py index c394ee6964..73fa220367 100644 --- a/move.py +++ b/move.py @@ -70,8 +70,9 @@ class Move(OSV): 'with date outside the period!', }) - def _auto_init(self, cursor, module_name): - super(Move, self)._auto_init(cursor, module_name) + def init(self, cursor, module_name): + super(Move, self).init(cursor, module_name) + cursor.execute('SELECT indexname FROM pg_indexes ' \ 'WHERE indexname = \'account_move_journal_period_index\'') if not cursor.rowcount: @@ -1182,14 +1183,14 @@ class Line(OSV): journal_obj = self.pool.get('account.journal') period_obj = self.pool.get('account.period') if not context.get('journal') or not context.get('period'): - return False + return value journal = journal_obj.browse(cursor, user, context['journal'], context=context) period = period_obj.browse(cursor, user, context['period'], context=context) if journal and period: return journal.name + ': ' + period.name - return False + return value def fields_view_get(self, cursor, user, view_id=None, view_type='form', context=None, toolbar=False, hexmd5=None): @@ -1210,7 +1211,7 @@ class Line(OSV): xml = '\n' \ '\n' + 'colors="red:state==\'draft\'">\n' % title fields = [] for column in journal.view.columns: fields.append(column.field.name) diff --git a/tax.py b/tax.py index 83033bc510..42067c2e42 100644 --- a/tax.py +++ b/tax.py @@ -227,7 +227,7 @@ class Code(OSV): return [(r['id'], r['code'] and r['code'] + ' - ' + \ unicode(r[self._rec_name]) or unicode(r[self._rec_name])) for r in self.read(cursor, user, ids, - [self._rec_name, 'code'], context=context, load='_classic_write')] + [self._rec_name, 'code'], context=context)] def delete(self, cursor, user, ids, context=None): if isinstance(ids, (int, long)):