first commit
This commit is contained in:
2
modules/sale_product_quantity/tests/__init__.py
Normal file
2
modules/sale_product_quantity/tests/__init__.py
Normal 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.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,95 @@
|
||||
==============================
|
||||
Sale Product Quantity Scenario
|
||||
==============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('sale_product_quantity', create_company)
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> customer = Party(name="Customer")
|
||||
>>> customer.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> gr, = ProductUom.find([('name', '=', "Gram")])
|
||||
>>> kg, = ProductUom.find([('name', '=', "Kilogram")])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Product"
|
||||
>>> template.default_uom = gr
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.salable = True
|
||||
>>> template.sale_uom = kg
|
||||
>>> template.sale_quantity_minimal = 0.1
|
||||
>>> template.sale_quantity_rounding = 0.05
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Make a sale::
|
||||
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity
|
||||
0.1
|
||||
>>> sale.save()
|
||||
|
||||
Can not set quantity below minimal::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 0.05
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
|
||||
Can not set quantity different than rounding::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 1.01
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
|
||||
Use different unit::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.unit = gr
|
||||
>>> line.quantity = 500
|
||||
>>> sale.save()
|
||||
|
||||
Can not set quantity below minimal::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 50
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
|
||||
Can not set quantity different than rounding::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 505
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
@@ -0,0 +1,93 @@
|
||||
==================================
|
||||
Sale Product Quantity POS Scenario
|
||||
==================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['sale_product_quantity', 'sale_point'],
|
||||
... create_company)
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> Location = Model.get('stock.location')
|
||||
>>> POS = Model.get('sale.point')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> Sale = Model.get('sale.point.sale')
|
||||
>>> SequenceStrict = Model.get('ir.sequence.strict')
|
||||
>>> SequenceType = Model.get('ir.sequence.type')
|
||||
|
||||
Get journal::
|
||||
|
||||
>>> journal_revenue, = Journal.find([('type', '=', 'revenue')], limit=1)
|
||||
|
||||
Get stock locations::
|
||||
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
>>> customer_loc, = Location.find([('code', '=', 'CUS')])
|
||||
|
||||
Create POS::
|
||||
|
||||
>>> pos = POS(name="POS")
|
||||
>>> pos.journal = journal_revenue
|
||||
>>> pos.sequence = SequenceStrict(name="POS", company=pos.company)
|
||||
>>> pos.sequence.sequence_type, = SequenceType.find(
|
||||
... [('name', '=', "POS")], limit=1)
|
||||
>>> pos.sequence.save()
|
||||
>>> pos.storage_location = storage_loc
|
||||
>>> pos.customer_location = customer_loc
|
||||
>>> pos.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> gr, = ProductUom.find([('name', '=', "Gram")])
|
||||
>>> kg, = ProductUom.find([('name', '=', "Kilogram")])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = "Product"
|
||||
>>> template.default_uom = gr
|
||||
>>> template.type = 'goods'
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.salable = True
|
||||
>>> template.sale_uom = kg
|
||||
>>> template.sale_quantity_minimal = 0.1
|
||||
>>> template.sale_quantity_rounding = 0.05
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Make a sale::
|
||||
|
||||
>>> sale = Sale(point=pos)
|
||||
|
||||
>>> line = sale.lines.new()
|
||||
>>> line.product = product
|
||||
>>> line.quantity
|
||||
0.1
|
||||
>>> sale.save()
|
||||
|
||||
Can not set quantity below minimal::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 0.05
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
|
||||
Can not set quantity different than rounding::
|
||||
|
||||
>>> line, = sale.lines
|
||||
>>> line.quantity = 1.01
|
||||
>>> sale.save()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
SaleValidationError: ...
|
||||
13
modules/sale_product_quantity/tests/test_module.py
Normal file
13
modules/sale_product_quantity/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# 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 SaleProductQuantityTestCase(ModuleTestCase):
|
||||
'Test Sale Product Quantity module'
|
||||
module = 'sale_product_quantity'
|
||||
extras = ['sale_point']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/sale_product_quantity/tests/test_scenario.py
Normal file
8
modules/sale_product_quantity/tests/test_scenario.py
Normal 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