Create Sale Order
This commit is contained in:
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
BIN
tests/__pycache__/test_module.cpython-311.pyc
Normal file
BIN
tests/__pycache__/test_module.cpython-311.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_scenario.cpython-311.pyc
Normal file
BIN
tests/__pycache__/test_scenario.cpython-311.pyc
Normal file
Binary file not shown.
44
tests/scenario_sale_order.rst
Normal file
44
tests/scenario_sale_order.rst
Normal file
@@ -0,0 +1,44 @@
|
||||
=====================
|
||||
Sale Order Scenario
|
||||
=====================
|
||||
|
||||
Imports::
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> from decimal import Decimal
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
|
||||
Activate module::
|
||||
>>> config = activate_modules('sale_order', create_company)
|
||||
|
||||
Create party::
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> party = Party(name='Cristian')
|
||||
>>> party.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.list_price = Decimal('10')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
Create order::
|
||||
>>> SaleOrder = Model.get('sale.order')
|
||||
>>> order = SaleOrder()
|
||||
>>> order.party = party
|
||||
>>> order.pickup_location = "on_site"
|
||||
>>> order.save()
|
||||
>>> line1 = order.lines.new()
|
||||
>>> line1.product = product
|
||||
>>> line1.quantity = 4
|
||||
>>> line1.unitprice = 8400
|
||||
>>> line1.total_amount = 33600
|
||||
>>> order.save()
|
||||
|
||||
10
tests/test_module.py
Normal file
10
tests/test_module.py
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class SaleOrderTestCase(ModuleTestCase):
|
||||
"Test Sale Order module"
|
||||
module = 'sale_order'
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
tests/test_scenario.py
Normal file
8
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