Add rec_name instead of journal and period names.
issue2371 review29321002
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+25
-2
@@ -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, '')
|
||||
|
||||
|
||||
@@ -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,
|
||||
}])
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<form col="6">
|
||||
<label name="journal"/>
|
||||
<field name="journal"/>
|
||||
<label name="period"/>
|
||||
<field name="period"/>
|
||||
<label name="active"/>
|
||||
<field name="active"/>
|
||||
<label name="state"/>
|
||||
<field name="state" colspan="3"/>
|
||||
<field name="state" colspan="5"/>
|
||||
</form>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree keyword_open="1">
|
||||
<field name="name" icon="icon"/>
|
||||
<field name="rec_name" icon="icon"/>
|
||||
<field name="journal"/>
|
||||
<field name="period"/>
|
||||
<field name="state"/>
|
||||
|
||||
Reference in New Issue
Block a user