Initial import from Docker volume
This commit is contained in:
2
modules/sale_discount/tests/__init__.py
Executable file
2
modules/sale_discount/tests/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/sale_discount/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_discount/tests/__pycache__/__init__.cpython-311.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/__init__.cpython-311.pyc
Executable file
Binary file not shown.
BIN
modules/sale_discount/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_discount/tests/__pycache__/test_module.cpython-311.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/test_module.cpython-311.pyc
Executable file
Binary file not shown.
BIN
modules/sale_discount/tests/__pycache__/test_scenario.cpython-311.opt-1.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/test_scenario.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/sale_discount/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
BIN
modules/sale_discount/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
Binary file not shown.
83
modules/sale_discount/tests/scenario_sale_discount.rst
Executable file
83
modules/sale_discount/tests/scenario_sale_discount.rst
Executable file
@@ -0,0 +1,83 @@
|
||||
======================
|
||||
Sale Discount Scenario
|
||||
======================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company, get_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('sale_discount')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> 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.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create a sale::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity = 1
|
||||
>>> line.base_price
|
||||
Decimal('10.0000')
|
||||
>>> line.unit_price
|
||||
Decimal('10.0000')
|
||||
|
||||
Set a discount of 10%::
|
||||
|
||||
>>> line.discount_rate = Decimal('0.1')
|
||||
>>> line.unit_price
|
||||
Decimal('9.0000')
|
||||
>>> line.discount_amount
|
||||
Decimal('1.0000')
|
||||
>>> line.discount
|
||||
'10%'
|
||||
|
||||
>>> sale.save()
|
||||
>>> line, = sale.lines
|
||||
>>> line.unit_price
|
||||
Decimal('9.0000')
|
||||
>>> line.discount_amount
|
||||
Decimal('1.0000')
|
||||
>>> line.discount
|
||||
'10%'
|
||||
|
||||
Set a discount amount::
|
||||
|
||||
>>> line.discount_amount = Decimal('3.3333')
|
||||
>>> line.unit_price
|
||||
Decimal('6.6667')
|
||||
>>> line.discount_rate
|
||||
Decimal('0.3333')
|
||||
>>> line.discount
|
||||
'$3.3333'
|
||||
12
modules/sale_discount/tests/test_module.py
Executable file
12
modules/sale_discount/tests/test_module.py
Executable file
@@ -0,0 +1,12 @@
|
||||
# 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.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleDiscountTestCase(ModuleTestCase):
|
||||
'Test Sale Discount module'
|
||||
module = 'sale_discount'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_discount/tests/test_scenario.py
Executable file
8
modules/sale_discount/tests/test_scenario.py
Executable file
@@ -0,0 +1,8 @@
|
||||
# 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.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user