changeset 31ae2474470f in modules/product_cost_warehouse:default
details:
https://hg.tryton.org/modules/product_cost_warehouse?cmd=changeset&node=31ae2474470f
description:
Add warehouse to invoice line
This ensures that the cost price used for COGS lines come from the right
warehouse when it is computed per warehouse.
issue10568
review362161002
diffstat:
__init__.py | 5 +++++
account.py | 15 +++++++++++++++
setup.py | 1 +
tests/test_product_cost_warehouse.py | 2 +-
tryton.cfg | 1 +
5 files changed, 23 insertions(+), 1 deletions(-)
diffs (75 lines):
diff -r c23f2df38d52 -r 31ae2474470f __init__.py
--- a/__init__.py Wed Jul 28 00:37:51 2021 +0200
+++ b/__init__.py Thu Jul 29 09:06:38 2021 +0200
@@ -5,6 +5,7 @@
from . import ir
from . import company
from . import product
+from . import account
from . import stock
__all__ = ['register']
@@ -27,6 +28,10 @@
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',
depends=['product_cost_history'])
diff -r c23f2df38d52 -r 31ae2474470f account.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/account.py Thu Jul 29 09:06:38 2021 +0200
@@ -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 -r c23f2df38d52 -r 31ae2474470f setup.py
--- a/setup.py Wed Jul 28 00:37:51 2021 +0200
+++ b/setup.py Thu Jul 29 09:06:38 2021 +0200
@@ -68,6 +68,7 @@
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 -r c23f2df38d52 -r 31ae2474470f tests/test_product_cost_warehouse.py
--- a/tests/test_product_cost_warehouse.py Wed Jul 28 00:37:51 2021 +0200
+++ b/tests/test_product_cost_warehouse.py Thu Jul 29 09:06:38 2021 +0200
@@ -16,7 +16,7 @@
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 -r c23f2df38d52 -r 31ae2474470f tryton.cfg
--- a/tryton.cfg Wed Jul 28 00:37:51 2021 +0200
+++ b/tryton.cfg Thu Jul 29 09:06:38 2021 +0200
@@ -6,6 +6,7 @@
product
stock
extras_depend:
+ account_invoice_stock
account_stock_continental
product_cost_fifo
product_cost_history