/usr/lib/python3/dist-packages/trytond/modules/purchase_invoice_line_standalone/tests/scenario_purchase_invoice_line_standalone.rst is in tryton-modules-purchase-invoice-line-standalone 4.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | =========================================
Purchase Invoice Line Standalone Scenario
=========================================
Imports::
>>> import datetime
>>> from dateutil.relativedelta import relativedelta
>>> from decimal import Decimal
>>> from operator import attrgetter
>>> from proteus import Model, Wizard
>>> from trytond.tests.tools import activate_modules, set_user
>>> from trytond.modules.company.tests.tools import create_company, \
... get_company
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
... create_chart, get_accounts, create_tax, set_tax_code
>>> from trytond.modules.account_invoice.tests.tools import \
... set_fiscalyear_invoice_sequences, create_payment_term
>>> today = datetime.date.today()
Install purchase_invoice_line_standalone::
>>> current_config = activate_modules('purchase_invoice_line_standalone')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create an accountant user::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> accountant = User()
>>> accountant.name = 'Accountant'
>>> accountant.login = 'accountant'
>>> account_group, = Group.find([('name', '=', 'Account')])
>>> accountant.groups.append(account_group)
>>> accountant.save()
Create fiscal year::
>>> fiscalyear = set_fiscalyear_invoice_sequences(
... create_fiscalyear(company))
>>> fiscalyear.click('create_period')
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> receivable = accounts['receivable']
>>> revenue = accounts['revenue']
>>> expense = accounts['expense']
Create parties::
>>> Party = Model.get('party.party')
>>> supplier = Party(name='Supplier')
>>> supplier.save()
>>> 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.purchasable = True
>>> template.salable = True
>>> template.list_price = Decimal('10')
>>> template.cost_price_method = 'fixed'
>>> template.account_expense = expense
>>> template.account_revenue = revenue
>>> product, = template.products
>>> product.cost_price = Decimal('5')
>>> template.save()
>>> product, = template.products
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Purchase 5 products::
>>> Purchase = Model.get('purchase.purchase')
>>> PurchaseLine = Model.get('purchase.line')
>>> purchase = Purchase()
>>> purchase.party = supplier
>>> purchase.payment_term = payment_term
>>> purchase.invoice_method = 'order'
>>> purchase_line = PurchaseLine()
>>> purchase.lines.append(purchase_line)
>>> purchase_line.product = product
>>> purchase_line.quantity = 2.0
>>> purchase_line = PurchaseLine()
>>> purchase.lines.append(purchase_line)
>>> purchase_line.product = product
>>> purchase_line.quantity = 3.0
>>> purchase_line = PurchaseLine()
>>> purchase.lines.append(purchase_line)
>>> purchase_line.product = product
>>> purchase_line.quantity = 4.0
>>> purchase_line = PurchaseLine()
>>> purchase.lines.append(purchase_line)
>>> purchase_line.type = 'subtotal'
>>> purchase_line.description = 'Subtotal'
>>> purchase.click('quote')
>>> purchase.click('confirm')
>>> purchase.click('process')
>>> purchase.state
u'processing'
>>> purchase.reload()
>>> len(purchase.moves)
3
>>> len(purchase.shipment_returns)
0
>>> len(purchase.invoices)
0
>>> len(purchase.invoice_lines)
3
Create a supplier invoice::
>>> Invoice = Model.get('account.invoice')
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = supplier
>>> len(invoice.lines.find())
3
>>> line1 = invoice.lines.find()[0]
>>> invoice.lines.append(line1)
>>> invoice.save()
Create a supplier invoice with an accountant::
>>> set_user(accountant)
>>> Invoice = Model.get('account.invoice')
>>> Partner = Model.get('party.party')
>>> supplier, = Partner.find([('name', '=', 'Supplier')])
>>> invoice = Invoice()
>>> invoice.type = 'in'
>>> invoice.party = supplier
>>> len(invoice.lines.find())
2
>>> _ = [invoice.lines.append(l) for l in invoice.lines.find()]
>>> invoice.save()
>>> _ = invoice.lines.pop()
>>> invoice.save()
|