3
Creating a res.partner record
5
!record {model: res.partner, id: res_partner_a0}:
12
transport_by_air_lt: 3
14
transport_by_sea_lt: 4
16
transport_by_road_lt: 5
20
Creating a res.partner.address record
22
!record {model: res.partner.address, id: res_partner_address_0}:
23
partner_id: res_partner_a0
27
Creating a res.partner record
29
!record {model: res.partner, id: res_partner_b0}:
37
Creating a res.partner.address record
39
!record {model: res.partner.address, id: res_partner_address_1}:
40
partner_id: res_partner_b0
44
I create product template .
46
!record {model: product.template, id: product_template_p0}:
47
categ_id: product.cat0
51
procure_method: make_to_stock
55
uom_id: product.product_uom_unit
56
uom_po_id: product.product_uom_unit
59
Creating a product.product record
61
!record {model: product.product, id: product_product_p0}:
64
valuation: manual_periodic
69
product_tmpl_id: product_template_p0
73
Creating a product.supplierinfo record
75
!record {model: product.supplierinfo, id: product_supplierinfo_0}:
79
product_id: product_template_p0
83
Creating a product.supplierinfo record
85
!record {model: product.supplierinfo, id: product_supplierinfo_1}:
89
product_id: product_template_p0
94
Creating a sale.order record
96
!record {model: sale.order, id: sale_order_so0}:
100
company_id: base.main_company
101
date_order: '2011-04-13'
102
invoice_quantity: order
104
partner_id: res_partner_a0
105
partner_invoice_id: res_partner_address_0
106
partner_order_id: res_partner_address_0
107
partner_shipping_id: res_partner_address_0
108
picking_policy: direct
109
pricelist_id: product.list0
116
Creating a sale.order.line record
118
!record {model: sale.order.line, id: sale_order_line_p0}:
119
company_id: base.main_company
122
order_id: sale_order_so0
123
order_partner_id: res_partner_a0
125
product_id: product_product_p0
126
product_uom: product.product_uom_unit
128
salesman_id: base.user_admin
135
I check the sourcing line
138
!python {model: sale.order.line}: |
139
sol = self.browse(cr, uid, ref("sale_order_line_p0"))
143
for sourcing in sol.sourcing_line_ids:
145
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"))
146
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"))
147
assert sourcing.type == 'make_to_stock', 'sourcing type wrong'
148
assert sourcing.state == 'draft', 'sourcing state wrong'
149
assert sourcing.state == sourcing.sale_order_line_state, 'states wrong'
150
assert not sourcing.supplier.id, 'make_to_stock: sourcing has a supplier !'
152
sourcing.write({'type':'make_to_order', 'supplier':ref("res_partner_b0")})
154
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"))
155
assert sol.type == 'make_to_order', 'sol type is wrong after update of sourcing line (%s, %s)'%(sol.type, 'make_to_order')
157
assert count == 1, 'number of sourcing line wrong (%i)'%(count)
160
wf_service = netsvc.LocalService("workflow")
161
wf_service.trg_validate(uid, 'sale.order', ref("sale_order_so0"), 'order_confirm', cr)
163
self.pool.get('procurement.order').run_scheduler(cr, uid)
165
ids = self.pool.get('purchase.order').search(cr, uid, [('origin', '=', sol.order_id.name)])
168
for po in self.pool.get('purchase.order').browse(cr, uid, ids):
169
if po.partner_id.id == ref("res_partner_b0"):
172
assert count == 1, 'purchase order number does not match (%i, %i)'%(len(sol.order_id.order_line), count)
174
#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"))