changeset 93a0aaa43ab8 in modules/product_kit:default
details: 
https://hg.tryton.org/modules/product_kit?cmd=changeset&node=93a0aaa43ab8
description:
        Add test for copying products with components
diffstat:

 tests/scenario_product_kit_copy.rst |  73 +++++++++++++++++++++++++++++++++++++
 tests/test_product_kit.py           |   5 ++
 2 files changed, 78 insertions(+), 0 deletions(-)

diffs (92 lines):

diff -r 88a24c1e5a5d -r 93a0aaa43ab8 tests/scenario_product_kit_copy.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/scenario_product_kit_copy.rst       Mon Sep 06 09:59:55 2021 +0200
@@ -0,0 +1,73 @@
+=========================
+Product Kit Copy Scenario
+=========================
+
+Imports::
+
+    >>> from decimal import Decimal
+    >>> from proteus import Model, Wizard
+    >>> from trytond.tests.tools import activate_modules
+    >>> from trytond.modules.company.tests.tools import create_company
+
+Activate product_kit and stock::
+
+    >>> config = activate_modules('product_kit')
+
+Create company::
+
+    >>> _ = create_company()
+
+Create products::
+
+    >>> Uom = Model.get('product.uom')
+    >>> unit, = Uom.find([('name', '=', 'Unit')])
+    >>> meter, = Uom.find([('name', '=', "Meter")])
+    >>> ProductTemplate = Model.get('product.template')
+    >>> Product = Model.get('product.product')
+
+    >>> template = ProductTemplate()
+    >>> template.name = "Product 1"
+    >>> template.default_uom = unit
+    >>> template.type = 'goods'
+    >>> template.save()
+    >>> product1, = template.products
+    >>> product1.cost_price = Decimal('10.0000')
+    >>> product1.save()
+
+    >>> template = ProductTemplate()
+    >>> template.name = "Product 2"
+    >>> template.default_uom = meter
+    >>> template.type = 'goods'
+    >>> template.save()
+    >>> product2, = template.products
+    >>> product2.cost_price = Decimal('20.0000')
+    >>> product2.save()
+
+Create a kit::
+
+    >>> template = ProductTemplate()
+    >>> template.name = "Kit"
+    >>> template.default_uom = unit
+    >>> template.type = 'kit'
+    >>> template.save()
+    >>> kit, = template.products
+
+    >>> component = template.components.new()
+    >>> component.product = product1
+    >>> component.parent_product = kit
+    >>> component.quantity = 1
+    >>> component = template.components.new()
+    >>> component.product = product2
+    >>> component.parent_product = kit
+    >>> component.quantity = 1
+    >>> component.fixed = True
+    >>> template.save()
+
+Components are copied when copying the template::
+
+    >>> template_copy, = template.duplicate()
+    >>> product_copy, = template.products
+    >>> len(template_copy.components)
+    2
+    >>> len(product_copy.components)
+    2
diff -r 88a24c1e5a5d -r 93a0aaa43ab8 tests/test_product_kit.py
--- a/tests/test_product_kit.py Mon Sep 06 09:59:13 2021 +0200
+++ b/tests/test_product_kit.py Mon Sep 06 09:59:55 2021 +0200
@@ -26,6 +26,11 @@
             checker=doctest_checker,
             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     suite.addTests(doctest.DocFileSuite(
+            'scenario_product_kit_copy.rst',
+            tearDown=doctest_teardown, encoding='utf-8',
+            checker=doctest_checker,
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+    suite.addTests(doctest.DocFileSuite(
             'scenario_product_kit_sale.rst',
             tearDown=doctest_teardown, encoding='utf-8',
             checker=doctest_checker,

Reply via email to