Files
tryton/configuration.py
T
Cédric Krier dc6e017e2d Remove accounts from products
The edition of accounting categories are limited to accounting administrators.
If a product does not have an accounting category, the default value defined
on the configuration are used.

issue3805
review45111002
2018-06-20 12:09:04 +02:00

54 lines
1.9 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.pool import PoolMeta, Pool
from trytond.model import fields
from trytond.pyson import Eval
__all__ = ['Configuration', 'ConfigurationDefaultAccount']
class Configuration:
__metaclass__ = PoolMeta
__name__ = 'account.configuration'
default_category_account_expense = fields.MultiValue(fields.Many2One(
'account.account', 'Default Account Expense',
domain=[
('kind', '=', 'expense'),
('company', '=', Eval('context', {}).get('company', -1)),
]))
default_category_account_revenue = fields.MultiValue(fields.Many2One(
'account.account', 'Default Account Revenue',
domain=[
('kind', '=', 'revenue'),
('company', '=', Eval('context', {}).get('company', -1)),
]))
@classmethod
def multivalue_model(cls, field):
pool = Pool()
if field in {'default_category_account_expense',
'default_category_account_revenue'}:
return pool.get('account.configuration.default_account')
return super(Configuration, cls).multivalue_model(field)
class ConfigurationDefaultAccount:
__metaclass__ = PoolMeta
__name__ = 'account.configuration.default_account'
default_category_account_expense = fields.Many2One(
'account.account', "Default Account Expense",
domain=[
('kind', '=', 'expense'),
('company', '=', Eval('company', -1)),
],
depends=['company'])
default_category_account_revenue = fields.Many2One(
'account.account', "Default Account Revenue",
domain=[
('kind', '=', 'revenue'),
('company', '=', Eval('company', -1)),
],
depends=['company'])