diff --git a/__init__.py b/__init__.py index 42636607b7..fd0c2f799c 100644 --- a/__init__.py +++ b/__init__.py @@ -2,20 +2,19 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .product import * -from .stock import * -from .invoice import * -from .account import * +from . import product +from . import stock +from . import invoice +from . import account def register(): Pool.register( - Category, - CategoryAccount, - Template, - TemplateAccount, - Product, - Move, - InvoiceLine, - FiscalYear, + product.Category, + product.CategoryAccount, + product.Template, + product.Product, + stock.Move, + invoice.InvoiceLine, + account.FiscalYear, module='account_stock_anglo_saxon', type_='model') diff --git a/product.py b/product.py index c597653c1e..1ee3acc5e8 100644 --- a/product.py +++ b/product.py @@ -8,8 +8,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: @@ -76,66 +75,13 @@ class CategoryAccount: class Template: __metaclass__ = PoolMeta __name__ = 'product.template' - account_cogs = fields.MultiValue(fields.Many2One('account.account', - 'Account Cost of Goods Sold', domain=[ - ('kind', '!=', 'view'), - ('company', '=', Eval('context', {}).get('company', -1)), - ], - states={ - 'invisible': ((~Eval('context', {}).get('company')) - | Eval('account_category') - | (Eval('type') != 'goods')), - }, - help='This account will be used instead of the one defined ' - 'on the category.', - depends=['account_category', 'type'])) - - @classmethod - def multivalue_model(cls, field): - pool = Pool() - if field == 'account_cogs': - return pool.get('product.template.account') - return super(Template, cls).multivalue_model(field) @property - @account_used('account_cogs') + @account_used('account_cogs', 'account_category') def account_cogs_used(self): pass -class TemplateAccount: - __metaclass__ = PoolMeta - __name__ = 'product.template.account' - account_cogs = fields.Many2One( - 'account.account', "Account Cost of Goods Sold", - domain=[ - ('kind', '!=', 'view'), - ('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_cogs') - - 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.append('account_cogs') - value_names.append('account_cogs') - super(TemplateAccount, cls)._migrate_property( - field_names, value_names, fields) - - class Product: __metaclass__ = PoolMeta __name__ = 'product.product' diff --git a/product.xml b/product.xml index a0e768d098..b4a3ea60e5 100644 --- a/product.xml +++ b/product.xml @@ -10,11 +10,5 @@ this repository contains the full copyright notices and license terms. --> category_form - - product.template - - template_form - - diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst index b5d93689fe..9668bbb199 100644 --- a/tests/scenario_account_stock_anglo_saxon.rst +++ b/tests/scenario_account_stock_anglo_saxon.rst @@ -89,9 +89,6 @@ Create chart of accounts:: >>> stock_supplier = accounts['stock_supplier'] >>> cogs = accounts['cogs'] - >>> AccountJournal = Model.get('account.journal') - >>> stock_journal, = AccountJournal.find([('code', '=', 'STO')]) - Create parties:: >>> Party = Model.get('party.party') @@ -100,6 +97,21 @@ Create parties:: >>> customer = Party(name='Customer') >>> customer.save() +Create product 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_stock = stock + >>> account_category.account_cogs = cogs + >>> account_category.account_stock_supplier = stock_supplier + >>> account_category.account_stock_customer = stock_customer + >>> account_category.account_stock_production = stock_production + >>> account_category.account_stock_lost_found = stock_lost_found + >>> account_category.save() + Create product:: >>> ProductUom = Model.get('product.uom') @@ -114,17 +126,7 @@ Create product:: >>> template.list_price = Decimal('10') >>> template.cost_price_method = 'fixed' >>> template.lead_time = datetime.timedelta(0) - >>> template.account_expense = expense - >>> template.account_revenue = revenue - >>> template.account_stock = stock - >>> template.account_cogs = cogs - >>> template.account_stock_supplier = stock_supplier - >>> template.account_stock_customer = stock_customer - >>> template.account_stock_production = stock_production - >>> template.account_stock_lost_found = stock_lost_found - >>> template.account_journal_stock_supplier = stock_journal - >>> template.account_journal_stock_customer = stock_journal - >>> template.account_journal_stock_lost_found = stock_journal + >>> template.account_category = account_category >>> product, = template.products >>> product.cost_price = Decimal('5') >>> template.save() @@ -356,17 +358,7 @@ Now we will use a product with different unit of measure:: >>> template_by5.list_price = Decimal('10') >>> template_by5.cost_price_method = 'fixed' >>> template_by5.lead_time = datetime.timedelta(0) - >>> template_by5.account_expense = expense - >>> template_by5.account_revenue = revenue - >>> template_by5.account_stock = stock - >>> template_by5.account_cogs = cogs - >>> template_by5.account_stock_supplier = stock_supplier - >>> template_by5.account_stock_customer = stock_customer - >>> template_by5.account_stock_production = stock_production - >>> template_by5.account_stock_lost_found = stock_lost_found - >>> template_by5.account_journal_stock_supplier = stock_journal - >>> template_by5.account_journal_stock_customer = stock_journal - >>> template_by5.account_journal_stock_lost_found = stock_journal + >>> template_by5.account_category = account_category >>> product_by5, = template_by5.products >>> product_by5.cost_price = Decimal('5') >>> template_by5.save() diff --git a/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst index a938540b63..5d08eb9b0c 100644 --- a/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst +++ b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst @@ -103,9 +103,6 @@ Create chart of accounts:: >>> stock_supplier = accounts['stock_supplier'] >>> cogs = accounts['cogs'] - >>> AccountJournal = Model.get('account.journal') - >>> stock_journal, = AccountJournal.find([('code', '=', 'STO')]) - Create parties:: >>> Party = Model.get('party.party') @@ -114,6 +111,21 @@ Create parties:: >>> customer = Party(name='Customer') >>> customer.save() +Create product 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_stock = stock + >>> account_category.account_cogs = cogs + >>> account_category.account_stock_supplier = stock_supplier + >>> account_category.account_stock_customer = stock_customer + >>> account_category.account_stock_production = stock_production + >>> account_category.account_stock_lost_found = stock_lost_found + >>> account_category.save() + Create product:: >>> ProductUom = Model.get('product.uom') @@ -129,18 +141,8 @@ Create product:: >>> template.list_price = Decimal('10') >>> template.cost_price_method = 'fixed' >>> template.lead_time = datetime.timedelta(0) - >>> template.account_expense = expense - >>> template.account_revenue = revenue - >>> template.account_stock = stock - >>> template.account_cogs = cogs - >>> template.account_stock_supplier = stock_supplier - >>> template.account_stock_customer = stock_customer - >>> template.account_stock_production = stock_production - >>> template.account_stock_lost_found = stock_lost_found - >>> template.account_journal_stock_supplier = stock_journal - >>> template.account_journal_stock_customer = stock_journal - >>> template.account_journal_stock_lost_found = stock_journal >>> template.supply_on_sale = True + >>> template.account_category = account_category >>> product, = template.products >>> product.cost_price = Decimal('5') >>> template.save() diff --git a/view/template_form.xml b/view/template_form.xml deleted file mode 100644 index 637110c4d0..0000000000 --- a/view/template_form.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -