2
In order to test the purchase order followup in a
3
split move flow, we will create a purchase order with
4
one line, confirm it and see the result in the followup
5
tool. Confirm partially the move and see the changes in
10
!record {model: res.partner, id: supplier_split_flow}:
14
I create the address for the supplier
16
!record {model: res.partner.address, id: address_split_flow}:
18
partner_id: supplier_split_flow
20
I create a product category
22
!record {model: product.category, id: prod_cat_split_flow}:
27
!record {model: product.product, id: product_split_flow}:
28
categ_id: prod_cat_split_flow
33
procure_method: make_to_order
34
property_stock_inventory: stock.location_inventory
35
property_stock_procurement: stock.location_procurement
36
property_stock_production: stock.location_production
41
uom_id: product.product_uom_unit
42
uom_po_id: product.product_uom_unit
47
international_status: itc
49
I create a new Purchase order
51
!record {model: purchase.order, id: po_split_flow}:
52
company_id: base.main_company
53
date_order: !eval time.strftime('%Y-%m-%d')
55
location_id: stock.stock_location_stock
56
partner_address_id: address_split_flow
57
partner_id: supplier_split_flow
58
pricelist_id: purchase.list0
60
I create a line for the Purchase order
62
!record {model: purchase.order.line, id: pol_split_flow}:
63
product_uom: product.product_uom_unit
64
product_id: product_split_flow
65
order_id: po_split_flow
69
date_planned: !eval time.strftime('%Y-%m-%d')
71
I confirm the purchase order
73
!python {model: purchase.order}: |
75
wf_service = netsvc.LocalService("workflow")
76
wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_confirm', cr)
77
wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_approve', cr)
79
I launch the purchase followup wizard
81
!python {model: ir.actions.server}: |
82
context = {'active_id': ref('po_split_flow'),
83
'active_ids': [ref('po_split_flow')]}
84
res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
85
assert res != False, "Error on ir.actions.server launching"
87
I check if the wizard is related to the purchase order and if the information are ok
89
!python {model: purchase.order.followup}: |
90
wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
91
assert wiz_ids, "The created wizard is not linked to the Purchase Order"
92
for wiz in self.browse(cr, uid, wiz_ids, context=context):
93
assert len(wiz.line_ids) == 1, "Number of lines in the follow-up not corresponding to the number of lines in the purchase order"
94
for line in wiz.line_ids:
95
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
96
assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
97
assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
98
assert line.line_uom_id.id == ref('product.product_uom_unit'), "The UoM of the line is different than the UoM of the PO line"
100
#assert line.line_confirmed_date == 1, ""
101
assert line.line_shipped_rate == 0.00, "Shipped rate on the followup is different than the shipped rate of the PO"
102
assert not line.move_product_id, "Product of the move is displayed"
103
assert not line.move_product_qty, "Product of the move is displayed"
104
assert not line.move_uom_id, "Product of the move is displayed"
105
assert line.move_state == 'Available', 'State of the move is incorrect in the followup line'
106
self.unlink(cr, uid, wiz_ids, context=context)
108
Confirm partially the move (create a back order)
110
!python {model: stock.picking }: |
112
pick_ids = self.search(cr, uid, [('purchase_id', '=', ref('po_split_flow'))])
113
pick=self.browse(cr,uid,pick_ids[0])
114
move =pick.move_lines[0]
116
'partner_id':pick.address_id.partner_id.id,
117
'address_id': pick.address_id.id,
118
'delivery_date' : time.strftime('%Y-%m-%d')
120
partial_datas['move%s'%(move.id)]= {
121
'product_id': move.product_id,
123
'product_uom': move.product_uom.id,
125
self.do_partial(cr, uid, [pick_ids[0]],partial_datas)
127
I launch the purchase followup wizard
129
!python {model: ir.actions.server}: |
130
context = {'active_id': ref('po_split_flow'),
131
'active_ids': [ref('po_split_flow')]}
132
res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
133
assert res != False, "Error on ir.actions.server launching"
135
I check if the wizard is related to the purchase order and if the information are ok
137
!python {model: purchase.order.followup}: |
138
wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
139
assert wiz_ids, "The created wizard is not linked to the Purchase Order"
140
for wiz in self.browse(cr, uid, wiz_ids):
141
assert len(wiz.line_ids) == 2, "Number of lines in the follow-up not corresponding to the number of lines in the purchase order (2 :: %s)" % len(wiz.line_ids)
142
for line in wiz.line_ids:
143
if line.move_id.state == 'done':
144
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
145
assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
146
assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
147
assert line.line_uom_id.id == ref('product.product_uom_unit'), "The UoM of the line is different than the UoM of the PO line"
149
#assert line.line_confirmed_date == 1, ""
150
assert line.line_shipped_rate == 30.00, "Shipped rate on the followup is different than the shipped rate of the PO"
151
assert not line.move_product_id, "Product of the move is displayed"
152
assert line.move_product_qty == '3.00', "Product qty is not equal to 3.00"
153
assert not line.move_uom_id, "Product of the move is displayed"
154
assert line.move_state == 'Closed', 'State of the move is incorrect in the followup line'
156
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
157
assert not line.line_product_id.id, "Product of PO line is displayed in follow-up"
158
assert not line.line_product_qty, "The product qty of the line is different than the qty in the PO line"
159
assert not line.line_uom_id.id, "The UoM of the line is different than the UoM of the PO line"
161
#assert line.line_confirmed_date == 1, ""
162
assert line.line_shipped_rate == 'no-progressbar', "Shipped rate is displayed"
163
assert not line.move_product_id, "Product of the move is displayed"
164
assert line.move_product_qty == '7.00', "Product qty is not equal to 7.00"
165
assert not line.move_uom_id, "Product of the move is displayed"
166
assert line.move_state == 'Available', 'State of the move is incorrect in the followup line (Available :: %s)' % line.move_state
167
self.unlink(cr, uid, wiz_ids, context=context)