diff --git a/CHANGELOG b/CHANGELOG index f1135e013d..92d2e23f96 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Replace Journal-Period name by function field * Manage readonly state on Move Line * Add comparison amount on Balance Sheet and Income Statement diff --git a/journal.py b/journal.py index 0211f55ec5..2b69fe9325 100644 --- a/journal.py +++ b/journal.py @@ -276,7 +276,6 @@ class JournalCashContext(ModelView): class JournalPeriod(ModelSQL, ModelView): 'Journal - Period' __name__ = 'account.journal.period' - name = fields.Char('Name', size=None, required=True) journal = fields.Many2One('account.journal', 'Journal', required=True, ondelete='CASCADE', states=STATES, depends=DEPENDS) period = fields.Many2One('account.period', 'Period', required=True, @@ -297,7 +296,7 @@ class JournalPeriod(ModelSQL, ModelView): ('journal_period_uniq', Unique(t, t.journal, t.period), 'You can only open one journal per period.'), ] - cls._order.insert(0, ('name', 'ASC')) + cls._error_messages.update({ 'modify_del_journal_period': ('You can not modify/delete ' 'journal - period "%s" because it has moves.'), @@ -308,6 +307,16 @@ class JournalPeriod(ModelSQL, ModelView): '"%(period)s" is closed.'), }) + @classmethod + def __register__(cls, module_name): + TableHandler = backend.get('TableHandler') + + super(JournalPeriod, cls).__register__(module_name) + + table = TableHandler(cls, module_name) + # Migration from 4.2: remove name column + table.drop_column('name') + @staticmethod def default_active(): return True @@ -316,6 +325,20 @@ class JournalPeriod(ModelSQL, ModelView): def default_state(): return 'open' + def get_rec_name(self, name): + return '%s - %s' % (self.journal.rec_name, self.period.rec_name) + + @classmethod + def search_rec_name(cls, name, clause): + if clause[1].startswith('!') or clause[1].startswith('not '): + bool_op = 'AND' + else: + bool_op = 'OR' + return [bool_op, + [('journal.rec_name',) + tuple(clause[1:])], + [('period.rec_name',) + tuple(clause[1:])], + ] + def get_icon(self, name): return _ICONS.get(self.state, '') diff --git a/move.py b/move.py index 8d161a472f..c83640c553 100644 --- a/move.py +++ b/move.py @@ -1373,7 +1373,6 @@ class Line(ModelSQL, ModelView): journal_period.rec_name,)) else: JournalPeriod.create([{ - 'name': journal.name + ' - ' + period.name, 'journal': journal.id, 'period': period.id, }]) @@ -1682,7 +1681,6 @@ class OpenJournal(Wizard): ], limit=1) if not journal_periods: journal_period, = JournalPeriod.create([{ - 'name': journal.name + ' - ' + period.name, 'journal': journal.id, 'period': period.id, }]) diff --git a/view/journal_period_form.xml b/view/journal_period_form.xml index 0dc5669325..bf75dc9971 100644 --- a/view/journal_period_form.xml +++ b/view/journal_period_form.xml @@ -1,15 +1,13 @@ -
diff --git a/view/journal_period_tree.xml b/view/journal_period_tree.xml index b2f99be23d..2b40847a70 100644 --- a/view/journal_period_tree.xml +++ b/view/journal_period_tree.xml @@ -2,7 +2,7 @@