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
|
-
Creating a res.partner record
-
!record {model: res.partner, id: res_partner_a0}:
credit_limit: 0.0
debit_limit: 0.0
name: A
supplier: true
customer_lt: 1
procurement_lt: 2
transport_by_air_lt: 3
air_sequence: 1
transport_by_sea_lt: 4
sea_sequence: 2
transport_by_road_lt: 5
road_sequence: 3
-
Creating a res.partner.address record
-
!record {model: res.partner.address, id: res_partner_address_0}:
partner_id: res_partner_a0
street: A
-
Creating a res.partner record
-
!record {model: res.partner, id: res_partner_b0}:
credit_limit: 0.0
debit_limit: 0.0
name: B
supplier: true
-
Creating a res.partner.address record
-
!record {model: res.partner.address, id: res_partner_address_1}:
partner_id: res_partner_b0
street: B
-
I create product template .
-
!record {model: product.template, id: product_template_p0}:
categ_id: product.cat0
cost_method: standard
mes_type: fixed
name: P
procure_method: make_to_stock
standard_price: 160.0
supply_method: buy
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
-
Creating a product.product record
-
!record {model: product.product, id: product_product_p0}:
standard_price: 1.0
valuation: manual_periodic
volume: 0.0
warranty: 0.0
weight: 0.0
weight_net: 0.0
product_tmpl_id: product_template_p0
-
Creating a product.supplierinfo record
-
!record {model: product.supplierinfo, id: product_supplierinfo_0}:
delay: 1
min_qty: 0.0
name: res_partner_a0
product_id: product_template_p0
-
Creating a product.supplierinfo record
-
!record {model: product.supplierinfo, id: product_supplierinfo_1}:
delay: 1
min_qty: 0.0
name: res_partner_b0
product_id: product_template_p0
sequence: 10
-
Creating a sale.order record
-
!record {model: sale.order, id: sale_order_so0}:
amount_tax: 0.0
amount_total: 1.0
amount_untaxed: 1.0
company_id: base.main_company
date_order: '2011-04-13'
invoice_quantity: order
order_policy: manual
partner_id: res_partner_a0
partner_invoice_id: res_partner_address_0
partner_order_id: res_partner_address_0
partner_shipping_id: res_partner_address_0
picking_policy: direct
pricelist_id: product.list0
shop_id: sale.shop
priority: normal
categ: medical
-
Creating a sale.order.line record
-
!record {model: sale.order.line, id: sale_order_line_p0}:
company_id: base.main_company
delay: 7.0
name: P
order_id: sale_order_so0
order_partner_id: res_partner_a0
price_unit: 1.0
product_id: product_product_p0
product_uom: product.product_uom_unit
product_uom_qty: 1.0
salesman_id: base.user_admin
state: draft
th_weight: 0.0
type: make_to_stock
-
I check the sourcing line
-
!python {model: sale.order.line}: |
sol = self.browse(cr, uid, ref("sale_order_line_p0"))
count = 0
for sourcing in sol.sourcing_line_ids:
count = count + 1
assert sourcing.sale_order_id.id == ref("sale_order_so0"), 'sourcing line, sale order id is wrong (%i, %i)'%(sourcing.sale_order_id, ref("sale_order_so0"))
assert int(sourcing.sale_order_line_id) == ref("sale_order_line_p0"), 'sourcing line, sale order line id is wrong (%i, %i)'%(sourcing.sale_order_line_id, ref("sale_order_line_p0"))
assert sourcing.type == 'make_to_stock', 'sourcing type wrong'
assert sourcing.state == 'draft', 'sourcing state wrong'
assert sourcing.state == sourcing.sale_order_line_state, 'states wrong'
assert not sourcing.supplier.id, 'make_to_stock: sourcing has a supplier !'
sourcing.write({'type':'make_to_order', 'supplier':ref("res_partner_b0")})
assert int(sol.supplier) == ref("res_partner_b0"), 'sol supplier is wrong after update of sourcing line (%i, %i)'%(sol.supplier, ref("product_supplierinfo_1"))
assert sol.type == 'make_to_order', 'sol type is wrong after update of sourcing line (%s, %s)'%(sol.type, 'make_to_order')
assert count == 1, 'number of sourcing line wrong (%i)'%(count)
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'sale.order', ref("sale_order_so0"), 'order_confirm', cr)
self.pool.get('procurement.order').run_scheduler(cr, uid)
ids = self.pool.get('purchase.order').search(cr, uid, [('origin', '=', sol.order_id.name)])
count = 0
for po in self.pool.get('purchase.order').browse(cr, uid, ids):
if po.partner_id.id == ref("res_partner_b0"):
count = count + 1
assert count == 1, 'purchase order number does not match (%i, %i)'%(len(sol.order_id.order_line), count)
#assert sol.procurement_id.purchase_id.partner_id.id == ref("res_partner_b0"), 'partner is wrong for purchase order (%i, %i)'%(sol.procurement_id.purchase_id.partner_id.id, ref("res_partner_b0"))
|