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
This commit is contained in:
1 parent
4344dc7c08
commit
dc6e017e2d
12 files changed
+91
-409
No files matched your search
+2
-63
@@ -3,29 +3,15 @@
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond import backend
|
||||
|
||||
|
||||
__all__ = ['Configuration', 'ConfigurationDefaultAccount',
|
||||
'ProductConfiguration']
|
||||
__all__ = ['Configuration', 'ConfigurationDefaultAccount']
|
||||
|
||||
|
||||
class Configuration:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.configuration'
|
||||
|
||||
default_product_account_expense = fields.MultiValue(fields.Many2One(
|
||||
'account.account', 'Default Account Expense',
|
||||
domain=[
|
||||
('kind', '=', 'expense'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
]))
|
||||
default_product_account_revenue = fields.MultiValue(fields.Many2One(
|
||||
'account.account', 'Default Account Revenue',
|
||||
domain=[
|
||||
('kind', '=', 'revenue'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
]))
|
||||
default_category_account_expense = fields.MultiValue(fields.Many2One(
|
||||
'account.account', 'Default Account Expense',
|
||||
domain=[
|
||||
@@ -42,9 +28,7 @@ class Configuration:
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
pool = Pool()
|
||||
if field in {'default_product_account_expense',
|
||||
'default_product_account_revenue',
|
||||
'default_category_account_expense',
|
||||
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)
|
||||
@@ -53,20 +37,6 @@ class Configuration:
|
||||
class ConfigurationDefaultAccount:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'account.configuration.default_account'
|
||||
default_product_account_expense = fields.Many2One(
|
||||
'account.account', "Default Account Expense",
|
||||
domain=[
|
||||
('kind', '=', 'expense'),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
default_product_account_revenue = fields.Many2One(
|
||||
'account.account', "Default Account Revenue",
|
||||
domain=[
|
||||
('kind', '=', 'revenue'),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
default_category_account_expense = fields.Many2One(
|
||||
'account.account', "Default Account Expense",
|
||||
domain=[
|
||||
@@ -81,34 +51,3 @@ class ConfigurationDefaultAccount:
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
|
||||
class ProductConfiguration:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'product.configuration'
|
||||
|
||||
default_accounts_category = fields.Boolean(
|
||||
'Use Category\'s accounts by default')
|
||||
default_taxes_category = fields.Boolean(
|
||||
'Use Category\' taxes by default')
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
|
||||
# Migration from 3.8: rename default_account_category into
|
||||
# default_accounts_category
|
||||
table = TableHandler(cls, module_name)
|
||||
if table.column_exist('default_account_category'):
|
||||
table.column_rename(
|
||||
'default_account_category', 'default_accounts_category')
|
||||
|
||||
super(ProductConfiguration, cls).__register__(module_name)
|
||||
|
||||
@classmethod
|
||||
def default_default_accounts_category(cls):
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
def default_default_taxes_category(cls):
|
||||
return False
|
||||
Reference in new issue
Block a user