changeset 66c8ac6af50d in modules/product_cost_fifo:default
details: 
https://hg.tryton.org/modules/product_cost_fifo?cmd=changeset;node=66c8ac6af50d
description:
        Add test for FIFO cost price with no input

        issue8699
        review252351002
diffstat:

 tests/scenario_product_cost_fifo_no_in.rst |  98 ++++++++++++++++++++++++++++++
 tests/test_product_cost_fifo.py            |   5 +
 2 files changed, 103 insertions(+), 0 deletions(-)

diffs (115 lines):

diff -r ea82b7ca5eb1 -r 66c8ac6af50d tests/scenario_product_cost_fifo_no_in.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/scenario_product_cost_fifo_no_in.rst        Thu Oct 24 18:58:34 
2019 +0200
@@ -0,0 +1,98 @@
+===================================
+Stock FIFO Cost Price with no Input
+===================================
+
+Imports::
+
+    >>> import datetime
+    >>> from decimal import Decimal
+    >>> from proteus import Model
+    >>> from trytond.tests.tools import activate_modules
+    >>> from trytond.modules.company.tests.tools import create_company, \
+    ...     get_company
+    >>> today = datetime.date.today()
+
+Install product_cost_fifo Module::
+
+    >>> config = activate_modules('product_cost_fifo')
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Create product::
+
+    >>> ProductUom = Model.get('product.uom')
+    >>> ProductTemplate = Model.get('product.template')
+    >>> unit, = ProductUom.find([('name', '=', 'Unit')])
+
+    >>> template = ProductTemplate()
+    >>> template.name = 'Product'
+    >>> template.default_uom = unit
+    >>> template.type = 'goods'
+    >>> template.list_price = Decimal('300')
+    >>> template.cost_price_method = 'fifo'
+    >>> product, = template.products
+    >>> product.cost_price = Decimal('80')
+    >>> template.save()
+    >>> product, = template.products
+
+Get stock locations::
+
+    >>> Location = Model.get('stock.location')
+    >>> supplier_loc, = Location.find([('code', '=', 'SUP')])
+    >>> customer_loc, = Location.find([('code', '=', 'CUS')])
+    >>> storage_loc, = Location.find([('code', '=', 'STO')])
+
+Make 2 units of the product not available @ 60 and 80 ::
+
+    >>> StockMove = Model.get('stock.move')
+    >>> incoming_move = StockMove()
+    >>> incoming_move.product = product
+    >>> incoming_move.uom = unit
+    >>> incoming_move.quantity = 1
+    >>> incoming_move.from_location = supplier_loc
+    >>> incoming_move.to_location = storage_loc
+    >>> incoming_move.planned_date = today
+    >>> incoming_move.company = company
+    >>> incoming_move.unit_price = Decimal('60')
+    >>> incoming_move.currency = company.currency
+    >>> incoming_move.fifo_quantity = 1
+    >>> incoming_move.click('do')
+
+    >>> incoming_move = StockMove()
+    >>> incoming_move.product = product
+    >>> incoming_move.uom = unit
+    >>> incoming_move.quantity = 1
+    >>> incoming_move.from_location = supplier_loc
+    >>> incoming_move.to_location = storage_loc
+    >>> incoming_move.planned_date = today
+    >>> incoming_move.company = company
+    >>> incoming_move.unit_price = Decimal('80')
+    >>> incoming_move.currency = company.currency
+    >>> incoming_move.fifo_quantity = 1
+    >>> incoming_move.click('do')
+
+Sell 1 unit @ 200::
+
+    >>> StockMove = Model.get('stock.move')
+    >>> outgoing_move = StockMove()
+    >>> outgoing_move.product = product
+    >>> outgoing_move.uom = unit
+    >>> outgoing_move.quantity = 1
+    >>> outgoing_move.from_location = storage_loc
+    >>> outgoing_move.to_location = customer_loc
+    >>> outgoing_move.planned_date = today
+    >>> outgoing_move.company = company
+    >>> outgoing_move.unit_price = Decimal('200')
+    >>> outgoing_move.currency = company.currency
+    >>> outgoing_move.click('do')
+
+Check Cost Price FIFO is the current cost price::
+
+    >>> product.reload()
+    >>> product.cost_price
+    Decimal('70.0000')
+    >>> outgoing_move.cost_price
+    Decimal('70.0000')
diff -r ea82b7ca5eb1 -r 66c8ac6af50d tests/test_product_cost_fifo.py
--- a/tests/test_product_cost_fifo.py   Thu Oct 24 18:57:55 2019 +0200
+++ b/tests/test_product_cost_fifo.py   Thu Oct 24 18:58:34 2019 +0200
@@ -27,4 +27,9 @@
             tearDown=doctest_teardown, encoding='utf-8',
             checker=doctest_checker,
             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+    suite.addTests(doctest.DocFileSuite(
+            'scenario_product_cost_fifo_no_in.rst',
+            tearDown=doctest_teardown, encoding='utf-8',
+            checker=doctest_checker,
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     return suite

Reply via email to