changeset 5ad1972d3f00 in modules/purchase:default details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=5ad1972d3f00 description: Add test for product suppliers copy
issue9017 review315221002 diffstat: tests/scenario_purchase_copy_product_suppliers.rst | 58 ++++++++++++++++++++++ tests/test_purchase.py | 5 + 2 files changed, 63 insertions(+), 0 deletions(-) diffs (75 lines): diff -r c43a5ec13cf7 -r 5ad1972d3f00 tests/scenario_purchase_copy_product_suppliers.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/scenario_purchase_copy_product_suppliers.rst Fri May 01 20:32:01 2020 +0200 @@ -0,0 +1,58 @@ +======================================== +Purchase Copy Product Suppliers Scenario +======================================== + +Imports:: + + >>> 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 + +Install purchase:: + + >>> config = activate_modules('purchase') + +Create company:: + + >>> _ = create_company() + >>> company = get_company() + +Create party:: + + >>> Party = Model.get('party.party') + >>> supplier = Party(name='Supplier') + >>> supplier.save() + +Create a product with suppliers:: + + >>> ProductUom = Model.get('product.uom') + >>> unit, = ProductUom.find([('name', '=', 'Unit')]) + >>> ProductTemplate = Model.get('product.template') + + >>> template = ProductTemplate() + >>> template.name = 'product' + >>> template.default_uom = unit + >>> template.type = 'goods' + >>> template.purchasable = True + >>> template.list_price = Decimal('10') + >>> template.cost_price_method = 'fixed' + >>> product_supplier = template.product_suppliers.new() + >>> product_supplier.party = supplier + >>> template.save() + >>> product, = template.products + >>> product_supplier = product.product_suppliers.new() + >>> product_supplier.party = supplier + >>> product_supplier.template == template + True + >>> product.save() + +Supplier is copied when copying the template:: + + >>> template_copy, = template.duplicate() + >>> product_copy, = template_copy.products + >>> len(template_copy.product_suppliers) + 2 + >>> len(product_copy.product_suppliers) + 1 diff -r c43a5ec13cf7 -r 5ad1972d3f00 tests/test_purchase.py --- a/tests/test_purchase.py Fri May 01 20:31:02 2020 +0200 +++ b/tests/test_purchase.py Fri May 01 20:32:01 2020 +0200 @@ -127,4 +127,9 @@ tearDown=doctest_teardown, encoding='utf-8', optionflags=doctest.REPORT_ONLY_FIRST_FAILURE, checker=doctest_checker)) + suite.addTests(doctest.DocFileSuite( + 'scenario_purchase_copy_product_suppliers.rst', + tearDown=doctest_teardown, encoding='utf-8', + optionflags=doctest.REPORT_ONLY_FIRST_FAILURE, + checker=doctest_checker)) return suite