This file is indexed.

/usr/lib/python2.7/dist-packages/trytond/modules/sale_opportunity/tests/scenario_sale_opportunity.rst is in tryton-modules-sale-opportunity 4.2.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
=========================
Sale Opportunity Scenario
=========================

Imports::

    >>> from decimal import Decimal
    >>> from proteus import Model, Wizard
    >>> from trytond.tests.tools import activate_modules
    >>> from trytond.modules.company.tests.tools import create_company, \
    ...     get_company
    >>> from trytond.modules.account.tests.tools import create_chart, \
    ...     get_accounts
    >>> from trytond.modules.account_invoice.tests.tools import \
    ...     create_payment_term

Install sale_opportunity::

    >>> config = activate_modules('sale_opportunity')

Create company::

    >>> _ = create_company()
    >>> company = get_company()

Create chart of accounts::

    >>> _ = create_chart(company)
    >>> accounts = get_accounts(company)
    >>> revenue = accounts['revenue']

Create sale opportunity user::

    >>> User = Model.get('res.user')
    >>> Group = Model.get('res.group')
    >>> sale_opportunity_user = User()
    >>> sale_opportunity_user.name = 'Sale Opportunity'
    >>> sale_opportunity_user.login = 'sale_opportunity'
    >>> sale_opportunity_user.main_company = company
    >>> sale_opportunity_group, = Group.find(
    ...     [('name', '=', 'Sale Opportunity')])
    >>> sale_opportunity_user.groups.append(sale_opportunity_group)

    >>> Employee = Model.get('company.employee')
    >>> Party = Model.get('party.party')
    >>> employee_party = Party(name='Employee')
    >>> employee_party.save()
    >>> employee = Employee(party=employee_party)
    >>> employee.save()
    >>> sale_opportunity_user.employees.append(employee)
    >>> sale_opportunity_user.employee = employee

    >>> sale_opportunity_user.save()

Create sale user::

    >>> sale_user = User()
    >>> sale_user.name = 'Sale'
    >>> sale_user.login = 'sale'
    >>> sale_user.main_company = company
    >>> sale_group, = Group.find([('name', '=', 'Sales')])
    >>> sale_user.groups.append(sale_group)
    >>> sale_user.save()

Create party::

    >>> 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')
    >>> Product = Model.get('product.product')
    >>> product = Product()
    >>> template = ProductTemplate()
    >>> template.name = 'product'
    >>> template.default_uom = unit
    >>> template.type = 'goods'
    >>> template.salable = True
    >>> template.list_price = Decimal('10')
    >>> template.cost_price = Decimal('5')
    >>> template.cost_price_method = 'fixed'
    >>> template.account_revenue = revenue
    >>> template.save()
    >>> product.template = template
    >>> product.save()

Create payment term::

    >>> payment_term = create_payment_term()
    >>> payment_term.save()

Create an lead::

    >>> config.user = sale_opportunity_user.id
    >>> Opportunity = Model.get('sale.opportunity')
    >>> opportunity = Opportunity()
    >>> opportunity.employee = employee
    >>> opportunity.description = 'Opportunity'
    >>> opportunity.save()
    >>> opportunity.state
    u'lead'

Convert to opportunity::

    >>> opportunity.party = customer
    >>> opportunity.address, = customer.addresses
    >>> opportunity.payment_term = payment_term
    >>> opportunity.amount = Decimal(100)
    >>> opportunity.click('opportunity')
    >>> opportunity.state
    u'opportunity'

Add a line::

    >>> line = opportunity.lines.new()
    >>> line.product = product
    >>> line.quantity = 10
    >>> opportunity.save()

Convert to sale::

    >>> opportunity.click('convert')
    >>> opportunity.state
    u'converted'

Find the sale::

    >>> config.user = sale_user.id
    >>> Sale = Model.get('sale.sale')
    >>> sale, = Sale.find(
    ...     [('origin', '=', 'sale.opportunity,%s' % opportunity.id)])
    >>> line, = sale.lines
    >>> line.product == product
    True
    >>> line.quantity
    10.0

Quote different quantity::

    >>> line.quantity = 9
    >>> sale.click('quote')

Check opportunity amount updated::

    >>> config.user = sale_opportunity_user.id
    >>> opportunity.reload()
    >>> opportunity.amount
    Decimal('90.00')
    >>> opportunity.state
    u'converted'

Add a second quotation::

    >>> config.user = sale_user.id
    >>> second_sale = Sale()
    >>> second_sale.origin = opportunity
    >>> second_sale.party = customer
    >>> second_sale.payment_term = payment_term
    >>> line = second_sale.lines.new()
    >>> line.product = product
    >>> line.quantity = 1
    >>> second_sale.click('quote')

Check opportunity amount updated::

    >>> config.user = sale_opportunity_user.id
    >>> opportunity.reload()
    >>> opportunity.amount
    Decimal('100.00')
    >>> opportunity.state
    u'converted'

Cancel second quotation::

    >>> config.user = sale_user.id
    >>> second_sale.click('cancel')
    >>> second_sale.state
    u'cancel'

Check opportunity amount updated::

    >>> config.user = sale_opportunity_user.id
    >>> opportunity.reload()
    >>> opportunity.amount
    Decimal('90.00')
    >>> opportunity.state
    u'converted'

Won opportunity::

    >>> config.user = sale_user.id
    >>> sale.click('confirm')
    >>> config.user = sale_opportunity_user.id
    >>> opportunity.reload()
    >>> opportunity.state
    u'won'

Check opportunity state updated::

    >>> config.user = sale_opportunity_user.id
    >>> opportunity.reload()
    >>> opportunity.state
    u'won'