Remove accounts from products
issue3805 review45111002
This commit is contained in:
@@ -20,7 +20,6 @@ def register():
|
||||
product.Category,
|
||||
product.CategoryAccount,
|
||||
product.Template,
|
||||
product.TemplateAccount,
|
||||
product.Product,
|
||||
invoice.InvoiceLine,
|
||||
account.Configuration,
|
||||
|
||||
+3
-81
@@ -7,8 +7,7 @@ from trytond.pool import PoolMeta, Pool
|
||||
from trytond.modules.account_product.product import (
|
||||
account_used, template_property)
|
||||
|
||||
__all__ = ['Category', 'CategoryAccount', 'Template', 'TemplateAccount',
|
||||
'Product']
|
||||
__all__ = ['Category', 'CategoryAccount', 'Template', 'Product']
|
||||
|
||||
|
||||
class Category:
|
||||
@@ -104,35 +103,6 @@ class Template:
|
||||
'readonly': ~Eval('active', True),
|
||||
'invisible': Eval('type', '') != 'assets',
|
||||
}, depends=['active', 'type'])
|
||||
account_depreciation = fields.MultiValue(fields.Many2One('account.account',
|
||||
'Account Depreciation', domain=[
|
||||
('kind', '=', 'other'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
states={
|
||||
'readonly': ~Eval('active', True),
|
||||
'required': ~Eval('accounts_category') & Eval('depreciable'),
|
||||
'invisible': (~Eval('depreciable')
|
||||
| (Eval('type', '') != 'assets')
|
||||
| ~Eval('context', {}).get('company')
|
||||
| Eval('accounts_category')),
|
||||
},
|
||||
depends=['active', 'depreciable', 'type', 'accounts_category']))
|
||||
account_asset = fields.MultiValue(fields.Many2One('account.account',
|
||||
'Account Asset',
|
||||
domain=[
|
||||
('kind', '=', 'expense'),
|
||||
('company', '=', Eval('context', {}).get('company', -1)),
|
||||
],
|
||||
states={
|
||||
'readonly': ~Eval('active', True),
|
||||
'required': ~Eval('accounts_category') & Eval('depreciable'),
|
||||
'invisible': (~Eval('depreciable')
|
||||
| (Eval('type', '') != 'assets')
|
||||
| ~Eval('context', {}).get('company')
|
||||
| Eval('accounts_category')),
|
||||
},
|
||||
depends=['active', 'depreciable', 'type', 'accounts_category']))
|
||||
depreciation_duration = fields.Integer(
|
||||
"Depreciation Duration",
|
||||
states={
|
||||
@@ -143,65 +113,17 @@ class Template:
|
||||
depends=['active', 'depreciable', 'type'],
|
||||
help='In months')
|
||||
|
||||
@classmethod
|
||||
def multivalue_model(cls, field):
|
||||
pool = Pool()
|
||||
if field in {'account_depreciation', 'account_asset'}:
|
||||
return pool.get('product.template.account')
|
||||
return super(Template, cls).multivalue_model(field)
|
||||
|
||||
@property
|
||||
@account_used('account_depreciation')
|
||||
@account_used('account_depreciation', 'account_category')
|
||||
def account_depreciation_used(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
@account_used('account_asset')
|
||||
@account_used('account_asset', 'account_category')
|
||||
def account_asset_used(self):
|
||||
pass
|
||||
|
||||
|
||||
class TemplateAccount:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'product.template.account'
|
||||
account_depreciation = fields.Many2One(
|
||||
'account.account', "Account Depreciation",
|
||||
domain=[
|
||||
('kind', '=', 'other'),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
account_asset = fields.Many2One(
|
||||
'account.account', "Account Asset",
|
||||
domain=[
|
||||
('kind', '=', 'expense'),
|
||||
('company', '=', Eval('company', -1)),
|
||||
],
|
||||
depends=['company'])
|
||||
|
||||
@classmethod
|
||||
def __register__(cls, module_name):
|
||||
TableHandler = backend.get('TableHandler')
|
||||
exist = TableHandler.table_exist(cls._table)
|
||||
if exist:
|
||||
table = TableHandler(cls, module_name)
|
||||
exist &= (table.column_exist('account_depreciation')
|
||||
and table.column_exist('account_asset'))
|
||||
|
||||
super(TemplateAccount, cls).__register__(module_name)
|
||||
|
||||
if not exist:
|
||||
# Re-migration
|
||||
cls._migrate_property([], [], [])
|
||||
|
||||
@classmethod
|
||||
def _migrate_property(cls, field_names, value_names, fields):
|
||||
field_names.extend(['account_depreciation', 'account_asset'])
|
||||
value_names.extend(['account_depreciation', 'account_asset'])
|
||||
super(TemplateAccount, cls)._migrate_property(
|
||||
field_names, value_names, fields)
|
||||
|
||||
|
||||
class Product:
|
||||
__metaclass__ = PoolMeta
|
||||
__name__ = 'product.product'
|
||||
|
||||
@@ -43,6 +43,17 @@ Create chart of accounts::
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create an asset::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
@@ -55,11 +66,8 @@ Create an asset::
|
||||
>>> asset_template.type = 'assets'
|
||||
>>> asset_template.default_uom = unit
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.account_expense = expense
|
||||
>>> asset_template.account_revenue = revenue
|
||||
>>> asset_template.account_asset = asset_account
|
||||
>>> asset_template.account_depreciation = depreciation_account
|
||||
>>> asset_template.depreciation_duration = 24
|
||||
>>> asset_template.save()
|
||||
>>> asset_product, = asset_template.products
|
||||
|
||||
@@ -43,6 +43,17 @@ Create chart of accounts::
|
||||
>>> expense = accounts['expense']
|
||||
>>> depreciation_account = accounts['depreciation']
|
||||
|
||||
Create account category::
|
||||
|
||||
>>> ProductCategory = Model.get('product.category')
|
||||
>>> account_category = ProductCategory(name="Account Category")
|
||||
>>> account_category.accounting = True
|
||||
>>> account_category.account_expense = expense
|
||||
>>> account_category.account_revenue = revenue
|
||||
>>> account_category.account_asset = asset_account
|
||||
>>> account_category.account_depreciation = depreciation_account
|
||||
>>> account_category.save()
|
||||
|
||||
Create products::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
@@ -55,10 +66,7 @@ Create products::
|
||||
>>> asset_template.list_price = Decimal('1000')
|
||||
>>> asset_template.depreciable = True
|
||||
>>> asset_template.purchasable = True
|
||||
>>> asset_template.account_expense = expense
|
||||
>>> asset_template.account_revenue = revenue
|
||||
>>> asset_template.account_asset = asset_account
|
||||
>>> asset_template.account_depreciation = depreciation_account
|
||||
>>> asset_template.account_category = account_category
|
||||
>>> asset_template.depreciation_duration = 24
|
||||
>>> asset_template.save()
|
||||
>>> service_product, = asset_template.products
|
||||
@@ -69,8 +77,7 @@ Create products::
|
||||
>>> service_template.default_uom = unit
|
||||
>>> service_template.list_price = Decimal('10')
|
||||
>>> service_template.purchasable = True
|
||||
>>> service_template.account_expense = expense
|
||||
>>> service_template.account_revenue = revenue
|
||||
>>> service_template.account_category = account_category
|
||||
>>> service_template.save()
|
||||
>>> service_product, = service_template.products
|
||||
|
||||
|
||||
+1
-10
@@ -2,9 +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. -->
|
||||
<data>
|
||||
<xpath
|
||||
expr="/form/notebook/page[@id='accounting']/separator[@id='accounts']"
|
||||
position="before">
|
||||
<xpath expr="/form/notebook/page[@id='accounting']" position="inside">
|
||||
<separator string="Depreciation" name="depreciable"
|
||||
colspan="4"/>
|
||||
<label name="depreciable"/>
|
||||
@@ -12,11 +10,4 @@
|
||||
<label name="depreciation_duration"/>
|
||||
<field name="depreciation_duration"/>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='accounting']/field[@name='account_expense']"
|
||||
position="after">
|
||||
<label name="account_depreciation"/>
|
||||
<field name="account_depreciation"/>
|
||||
<label name="account_asset"/>
|
||||
<field name="account_asset"/>
|
||||
</xpath>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user