Files
tryton/modules/analytic_account/rule.py
T
Cédric Krier c1b2ed9425 Use type and closed to filter account on analytic rule instead of view type
The view type has been removed since 6b76c4de4813.

Closes #13641
(grafted from 2e21f51a811ddb72f09dd9eb5b2b647b709aa176)

--HG--
branch : 6.0
2024-11-01 08:59:13 +01:00

60 lines
1.8 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import ModelSQL, ModelView, MatchMixin, fields, \
sequence_ordered
from trytond.pyson import Eval
from trytond.transaction import Transaction
from .account import AnalyticMixin
class Rule(sequence_ordered(), MatchMixin, AnalyticMixin, ModelSQL, ModelView):
"Analytic Rule"
__name__ = 'analytic_account.rule'
company = fields.Many2One(
'company.company', "Company", required=True)
account = fields.Many2One(
'account.account', "Account",
domain=[
('company', '=', Eval('company', -1)),
('type', '!=', None),
('closed', '!=', True),
],
depends=['company'])
party = fields.Many2One(
'party.party', "Party",
states={
'invisible': ~Eval('party_visible'),
},
context={
'company': Eval('company', -1),
},
depends=['party_visible', 'company'])
party_visible = fields.Function(fields.Boolean("Party Visible"),
'on_change_with_party_visible')
journal = fields.Many2One(
'account.journal', "Journal",
context={
'company': Eval('company', -1),
},
depends=['company'])
@classmethod
def __setup__(cls):
super().__setup__()
cls.analytic_accounts.domain = [
('company', '=', Eval('company', -1)),
]
cls.analytic_accounts.depends.append('company')
@classmethod
def default_company(cls):
return Transaction().context.get('company')
@fields.depends('account')
def on_change_with_party_visible(self, name=None):
if self.account:
return self.account.party_required
return False