~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to sourcing/test/sourcing.yml

UF-73: [MERGE] Merge with unifield-wm branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
    
2
 
3
 
  Creating a res.partner record
4
 
5
 
  !record {model: res.partner, id: res_partner_a0}:
6
 
    credit_limit: 0.0
7
 
    debit_limit: 0.0
8
 
    name: A
9
 
    supplier: true
10
 
    customer_lt: 1
11
 
    procurement_lt: 2
12
 
    transport_0_lt: 3
13
 
    transport_0: 'air'
14
 
    
15
 
16
 
  Creating a res.partner.address record
17
 
18
 
  !record {model: res.partner.address, id: res_partner_address_0}:
19
 
    partner_id: res_partner_a0
20
 
    street: A
21
 
    
22
 
23
 
  Creating a res.partner record
24
 
25
 
  !record {model: res.partner, id: res_partner_b0}:
26
 
    credit_limit: 0.0
27
 
    debit_limit: 0.0
28
 
    name: B
29
 
    supplier: true
30
 
    
31
 
    
32
 
33
 
  Creating a res.partner.address record
34
 
35
 
  !record {model: res.partner.address, id: res_partner_address_1}:
36
 
    partner_id: res_partner_b0
37
 
    street: B
38
 
    
39
 
-
40
 
  I create product template .
41
 
-
42
 
  !record {model: product.template, id: product_template_p0}:
43
 
    categ_id: product.cat0
44
 
    cost_method: standard
45
 
    mes_type: fixed
46
 
    name: P
47
 
    procure_method: make_to_stock
48
 
    standard_price: 160.0
49
 
    supply_method: buy
50
 
    type: product
51
 
    uom_id: product.product_uom_unit
52
 
    uom_po_id: product.product_uom_unit
53
 
    
54
 
55
 
  Creating a product.product record
56
 
57
 
  !record {model: product.product, id: product_product_p0}:
58
 
    
59
 
    standard_price: 1.0
60
 
    valuation: manual_periodic
61
 
    volume: 0.0
62
 
    warranty: 0.0
63
 
    weight: 0.0
64
 
    weight_net: 0.0
65
 
    product_tmpl_id: product_template_p0
66
 
    international_status: itc
67
 
    
68
 
    
69
 
70
 
  Creating a product.supplierinfo record
71
 
72
 
  !record {model: product.supplierinfo, id: product_supplierinfo_0}:
73
 
    delay: 1
74
 
    min_qty: 0.0
75
 
    name: res_partner_a0
76
 
    product_id: product_template_p0
77
 
    
78
 
    
79
 
80
 
  Creating a product.supplierinfo record
81
 
82
 
  !record {model: product.supplierinfo, id: product_supplierinfo_1}:
83
 
    delay: 1
84
 
    min_qty: 0.0
85
 
    name: res_partner_b0
86
 
    product_id: product_template_p0
87
 
    sequence: 10
88
 
    
89
 
    
90
 
91
 
  Creating a sale.order record
92
 
93
 
  !record {model: sale.order, id: sale_order_so0}:
94
 
    amount_tax: 0.0
95
 
    amount_total: 1.0
96
 
    amount_untaxed: 1.0
97
 
    company_id: base.main_company
98
 
    date_order: '2011-04-13'
99
 
    invoice_quantity: order
100
 
    order_policy: manual
101
 
    partner_id: res_partner_a0
102
 
    partner_invoice_id: res_partner_address_0
103
 
    partner_order_id: res_partner_address_0
104
 
    partner_shipping_id: res_partner_address_0
105
 
    picking_policy: direct
106
 
    pricelist_id: product.list0
107
 
    shop_id: sale.shop
108
 
    priority: normal
109
 
    categ: medical
110
 
    
111
 
    
112
 
113
 
  Creating a sale.order.line record
114
 
115
 
  !record {model: sale.order.line, id: sale_order_line_p0}:
116
 
    company_id: base.main_company
117
 
    delay: 7.0
118
 
    name: P
119
 
    order_id: sale_order_so0
120
 
    order_partner_id: res_partner_a0
121
 
    price_unit: 1.0
122
 
    product_id: product_product_p0
123
 
    product_uom: product.product_uom_unit
124
 
    product_uom_qty: 1.0
125
 
    salesman_id: base.user_admin
126
 
    state: draft
127
 
    th_weight: 0.0
128
 
    type: make_to_stock
129
 
    
130
 
-
131
 
 
132
 
  I check the sourcing line
133
 
 
134
 
-
135
 
  !python {model: sale.order.line}: |
136
 
    sol = self.browse(cr, uid, ref("sale_order_line_p0"))
137
 
    
138
 
    count = 0
139
 
    
140
 
    for sourcing in sol.sourcing_line_ids:
141
 
      count = count + 1
142
 
      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"))
143
 
      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"))
144
 
      assert sourcing.type == 'make_to_stock', 'sourcing type wrong'
145
 
      assert sourcing.state == 'draft', 'sourcing state wrong'
146
 
      assert sourcing.state == sourcing.sale_order_line_state, 'states wrong'
147
 
      assert not sourcing.supplier.id, 'make_to_stock: sourcing has a supplier !'
148
 
      
149
 
      sourcing.write({'type':'make_to_order', 'supplier':ref("res_partner_b0"), 'po_cft':'po'})
150
 
      
151
 
      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"))
152
 
      assert sol.type == 'make_to_order', 'sol type is wrong after update of sourcing line (%s, %s)'%(sol.type, 'make_to_order')
153
 
      
154
 
    assert count == 1, 'number of sourcing line wrong (%i)'%(count)
155
 
    
156
 
    import netsvc
157
 
    wf_service = netsvc.LocalService("workflow")
158
 
    wf_service.trg_validate(uid, 'sale.order', ref("sale_order_so0"), 'order_confirm', cr)
159
 
    
160
 
    self.pool.get('procurement.order').run_scheduler(cr, uid)
161
 
    
162
 
    ids = self.pool.get('purchase.order').search(cr, uid, [('origin', '=', sol.order_id.name)])
163
 
    
164
 
    count = 0
165
 
    for po in self.pool.get('purchase.order').browse(cr, uid, ids):
166
 
      if po.partner_id.id == ref("res_partner_b0"):
167
 
        count = count + 1
168
 
    
169
 
    assert count == 1, 'purchase order number does not match (%i, %i)'%(len(sol.order_id.order_line), count)
170
 
    
171
 
    #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"))
172