trytondo-sale_order/tests/scenario_sale_order.rst

48 lines
1.3 KiB
ReStructuredText

=====================
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.unit = unit
>>> line1.quantity = 4.0
>>> line1.unitprice = Decimal('8400')
>>> line1.total_amount = Decimal('33600')
>>> order.total_order = Decimal('33600')
>>> order.save()