changeset 422e4fd3b392 in modules/product_kit:default details: https://hg.tryton.org/modules/product_kit?cmd=changeset&node=422e4fd3b392 description: Add scenario to test kit duplication
issue11854 review418561003 diffstat: tests/scenario_product_kit_duplicate.rst | 86 ++++++++++++++++++++++++++++++++ 1 files changed, 86 insertions(+), 0 deletions(-) diffs (90 lines): diff -r 699d42badcf0 -r 422e4fd3b392 tests/scenario_product_kit_duplicate.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/scenario_product_kit_duplicate.rst Thu Nov 03 09:18:11 2022 +0100 @@ -0,0 +1,86 @@ +============================== +Product Kit Duplicate 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, get_company) + +Activate product_kit:: + + >>> config = activate_modules('product_kit') + + >>> Uom = Model.get('product.uom') + >>> ProductTemplate = Model.get('product.template') + >>> Product = Model.get('product.product') + +Create company:: + + >>> _ = create_company() + >>> company = get_company() + +Create products:: + + >>> unit, = Uom.find([('name', '=', 'Unit')]) + >>> 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 = unit + >>> template.type = 'goods' + >>> template.save() + >>> product2, = template.products + >>> product2.cost_price = Decimal('20.0000') + >>> product2.save() + +Create composed product:: + + >>> template = ProductTemplate() + >>> template.name = "Composed Product" + >>> template.default_uom = unit + >>> template.type = 'goods' + >>> template.save() + >>> composed_product, = template.products + >>> composed_product.cost_price = Decimal('10.0000') + + >>> component = composed_product.components.new() + >>> component.product = product1 + >>> component.quantity = 2 + >>> composed_product.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.quantity = 1 + >>> component = template.components.new() + >>> component.product = product2 + >>> component.quantity = 2 + >>> template.save() + +Test duplicate copies components:: + + >>> duplicated, = template.duplicate() + >>> len(duplicated.components) + 2 + >>> duplicated_product, = composed_product.duplicate() + >>> len(duplicated_product.components) + 1