diff --git a/__init__.py b/__init__.py index 60c7057b79..b28dbd077b 100644 --- a/__init__.py +++ b/__init__.py @@ -5,6 +5,7 @@ from trytond.pool import Pool from . import ir from . import company from . import product +from . import account from . import stock __all__ = ['register'] @@ -26,6 +27,10 @@ def register(): stock.Move, stock.ShipmentInternal, module='product_cost_warehouse', type_='model') + Pool.register( + account.InvoiceLine, + module='product_cost_warehouse', type_='model', + depends=['account_invoice_stock']) Pool.register( product.ProductCostHistory, module='product_cost_warehouse', type_='model', diff --git a/account.py b/account.py new file mode 100644 index 0000000000..ed5aa1513b --- /dev/null +++ b/account.py @@ -0,0 +1,15 @@ +# 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 +from trytond.pyson import Eval + + +class InvoiceLine(metaclass=PoolMeta): + __name__ = 'account.invoice.line' + + @classmethod + def __setup__(cls): + super().__setup__() + cls.product.context['warehouse'] = Eval('warehouse', -1) + if 'warehouse' not in cls.product.depends: + cls.product.depends.append('warehouse') diff --git a/setup.py b/setup.py index 0901bd745f..c28de78c79 100755 --- a/setup.py +++ b/setup.py @@ -68,6 +68,7 @@ requires.append(get_require_version('trytond')) tests_require = [ get_require_version('proteus'), + get_require_version('trytond_account_invoice_stock'), get_require_version('trytond_product_cost_fifo'), get_require_version('trytond_product_cost_history'), get_require_version('trytond_account_stock_continental'), diff --git a/tests/test_product_cost_warehouse.py b/tests/test_product_cost_warehouse.py index e353e5382f..678b5d85c2 100644 --- a/tests/test_product_cost_warehouse.py +++ b/tests/test_product_cost_warehouse.py @@ -16,7 +16,7 @@ from trytond.modules.company.tests import CompanyTestMixin class ProductCostWarehouseTestCase(CompanyTestMixin, ModuleTestCase): 'Test Product Cost Warehouse module' module = 'product_cost_warehouse' - extras = ['product_cost_history'] + extras = ['account_invoice_stock', 'product_cost_history'] def suite(): diff --git a/tryton.cfg b/tryton.cfg index cc4239e74c..6618ddc28b 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -6,6 +6,7 @@ depends: product stock extras_depend: + account_invoice_stock account_stock_continental product_cost_fifo product_cost_history