Add extra depends, and update the domian of account_expense field depending on this extra modules
This commit is contained in:
parent
ec81ad51b7
commit
a5e8e5f561
|
@ -5,6 +5,7 @@ from . import account
|
|||
from . import currency
|
||||
from . import tax
|
||||
from . import invoice
|
||||
from . import product
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -23,4 +24,7 @@ def register():
|
|||
tax.TaxRuleLineTemplate,
|
||||
invoice.Invoice,
|
||||
invoice.InvoiceLine,
|
||||
product.Category,
|
||||
product.CategoryAccount,
|
||||
product.Template,
|
||||
module='account_es', type_='model')
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
from trytond.pool import Pool, PoolMeta
|
||||
from trytond.pyson import Eval
|
||||
|
||||
__all__ = ['Category', 'CategoryAccount', 'Template']
|
||||
|
||||
|
||||
class Category(metaclass=PoolMeta):
|
||||
__name__ = 'product.category'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
pool = Pool()
|
||||
AccountType = pool.get('account.account.type')
|
||||
|
||||
super().__setup__()
|
||||
|
||||
# Related to module account_product
|
||||
if hasattr(cls, 'account_expense'):
|
||||
if hasattr(AccountType, 'fixed_asset'):
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
['OR',
|
||||
[
|
||||
('type.supplier_balance', '=', True),
|
||||
('type.fixed_asset', '=', False),
|
||||
],
|
||||
('type.expense', '=', True),
|
||||
],
|
||||
]
|
||||
else:
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
['OR',
|
||||
('type.expense', '=', True),
|
||||
('type.supplier_balance', '=', True),
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
class CategoryAccount(metaclass=PoolMeta):
|
||||
__name__ = 'product.category.account'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
pool = Pool()
|
||||
AccountType = pool.get('account.account.type')
|
||||
|
||||
super().__setup__()
|
||||
|
||||
# Related to module account_product
|
||||
if hasattr(cls, 'account_expense'):
|
||||
if hasattr(AccountType, 'fixed_asset'):
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('company', -1)),
|
||||
['OR',
|
||||
[
|
||||
('type.supplier_balance', '=', True),
|
||||
('type.fixed_asset', '=', False),
|
||||
],
|
||||
('type.expense', '=', True),
|
||||
],
|
||||
]
|
||||
else:
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('company', -1)),
|
||||
['OR',
|
||||
('type.expense', '=', True),
|
||||
('type.supplier_balance', '=', True),
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
class Template(metaclass=PoolMeta):
|
||||
__name__ = 'product.template'
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
pool = Pool()
|
||||
AccountType = pool.get('account.account.type')
|
||||
|
||||
super().__setup__()
|
||||
|
||||
# Related to module account_product_accounting
|
||||
if hasattr(cls, 'account_expense'):
|
||||
if hasattr(AccountType, 'fixed_asset'):
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
['OR',
|
||||
[
|
||||
('type.supplier_balance', '=', True),
|
||||
('type.fixed_asset', '=', False),
|
||||
],
|
||||
('type.expense', '=', True),
|
||||
],
|
||||
]
|
||||
else:
|
||||
cls.account_expense.domain = [
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
['OR',
|
||||
('type.expense', '=', True),
|
||||
('type.supplier_balance', '=', True),
|
||||
],
|
||||
]
|
|
@ -4,6 +4,10 @@ depends:
|
|||
ir
|
||||
account
|
||||
account_invoice
|
||||
extra_depends:
|
||||
account_asset
|
||||
account_product
|
||||
account_product_accounting
|
||||
xml:
|
||||
account.xml
|
||||
view.xml
|
||||
|
|
Loading…
Reference in New Issue