Add company to journal-period

This commit is contained in:
Cédric Krier
2024-03-14 14:04:31 +01:00
parent 0a14c86d4e
commit 36cf314066
4 changed files with 26 additions and 4 deletions
+18 -2
View File
@@ -228,10 +228,18 @@ class JournalCashContext(ModelView):
class JournalPeriod(Workflow, ModelSQL, ModelView):
'Journal - Period'
__name__ = 'account.journal.period'
journal = fields.Many2One('account.journal', 'Journal', required=True,
ondelete='CASCADE', states=STATES)
journal = fields.Many2One(
'account.journal', 'Journal', required=True, ondelete='CASCADE',
states=STATES,
context={
'company': Eval('company', None),
},
depends=['company'])
period = fields.Many2One('account.period', 'Period', required=True,
ondelete='CASCADE', states=STATES)
company = fields.Function(fields.Many2One(
'company.company', "Company"),
'on_change_with_company', searcher='search_company')
icon = fields.Function(fields.Char('Icon'), 'get_icon')
state = fields.Selection([
('open', 'Open'),
@@ -270,6 +278,14 @@ class JournalPeriod(Workflow, ModelSQL, ModelView):
cursor.execute(
*t.update([t.state], ['closed'], where=t.state == 'close'))
@fields.depends('period')
def on_change_with_company(self, name=None):
return self.period.company if self.period else None
@classmethod
def search_company(cls, name, clause):
return [('period.' + clause[0], *clause[1:])]
@staticmethod
def default_state():
return 'open'
+6 -2
View File
@@ -2,10 +2,14 @@
<!-- 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="journal"/>
<field name="journal" widget="selection"/>
<label name="period"/>
<field name="period"/>
<label name="company"/>
<field name="company"/>
<label name="journal"/>
<field name="journal" widget="selection"/>
<newline/>
<label name="state"/>
<field name="state" colspan="4"/>
@@ -2,6 +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>
<field name="company" expand="1" optional="1"/>
<field name="journal" icon="icon" expand="1"/>
<field name="period" expand="1"/>
<button name="reopen" string="Re-Open"/>
@@ -2,6 +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="company" expand="1" optional="1"/>
<field name="journal" expand="1"/>
<field name="period" expand="1"/>
<field name="state"/>