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
48
I create a new Purchase order
50
!record {model: purchase.order, id: po_split_flow}:
51
company_id: base.main_company
52
date_order: !eval time.strftime('%Y-%m-%d')
54
location_id: stock.stock_location_stock
55
partner_address_id: address_split_flow
56
partner_id: supplier_split_flow
57
pricelist_id: purchase.list0
59
I create a line for the Purchase order
61
!record {model: purchase.order.line, id: pol_split_flow}:
62
product_uom: product.product_uom_unit
63
product_id: product_split_flow
64
order_id: po_split_flow
68
date_planned: !eval time.strftime('%Y-%m-%d')
70
I confirm the purchase order
72
!python {model: purchase.order}: |
74
wf_service = netsvc.LocalService("workflow")
75
wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_confirm', cr)
76
wf_service.trg_validate(uid, 'purchase.order', ref('po_split_flow'), 'purchase_approve', cr)
78
I launch the purchase followup wizard
80
!python {model: ir.actions.server}: |
81
context = {'active_id': ref('po_split_flow'),
82
'active_ids': [ref('po_split_flow')]}
83
res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
84
assert res != False, "Error on ir.actions.server launching"
86
I check if the wizard is related to the purchase order and if the information are ok
88
!python {model: purchase.order.followup}: |
89
wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
90
assert wiz_ids, "The created wizard is not linked to the Purchase Order"
91
for wiz in self.browse(cr, uid, wiz_ids, context=context):
92
assert len(wiz.line_ids) == 1, "Number of lines in the follow-up not corresponding to the number of lines in the purchase order"
93
for line in wiz.line_ids:
94
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
95
assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
96
assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
97
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"
99
#assert line.line_confirmed_date == 1, ""
100
assert line.line_shipped_rate == 0.00, "Shipped rate on the followup is different than the shipped rate of the PO"
101
assert not line.move_product_id, "Product of the move is displayed"
102
assert not line.move_product_qty, "Product of the move is displayed"
103
assert not line.move_uom_id, "Product of the move is displayed"
104
assert line.move_state == 'Available', 'State of the move is incorrect in the followup line'
105
self.unlink(cr, uid, wiz_ids, context=context)
107
Confirm partially the move (create a back order)
109
!python {model: stock.picking }: |
111
pick_ids = self.search(cr, uid, [('purchase_id', '=', ref('po_split_flow'))])
112
pick=self.browse(cr,uid,pick_ids[0])
113
move =pick.move_lines[0]
115
'partner_id':pick.address_id.partner_id.id,
116
'address_id': pick.address_id.id,
117
'delivery_date' : time.strftime('%Y-%m-%d')
119
partial_datas['move%s'%(move.id)]= {
120
'product_id': move.product_id,
122
'product_uom': move.product_uom.id,
124
self.do_partial(cr, uid, [pick_ids[0]],partial_datas)
126
I launch the purchase followup wizard
128
!python {model: ir.actions.server}: |
129
context = {'active_id': ref('po_split_flow'),
130
'active_ids': [ref('po_split_flow')]}
131
res = self.run(cr, uid, [ref('action_purchase_order_follow_up')], context)
132
assert res != False, "Error on ir.actions.server launching"
134
I check if the wizard is related to the purchase order and if the information are ok
136
!python {model: purchase.order.followup}: |
137
wiz_ids = self.search(cr, uid, [('order_id', '=', ref('po_split_flow'))])
138
assert wiz_ids, "The created wizard is not linked to the Purchase Order"
139
for wiz in self.browse(cr, uid, wiz_ids):
140
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)
141
for line in wiz.line_ids:
142
if line.move_id.product_qty == 7.00:
143
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
144
assert line.line_product_id.id == ref('product_split_flow'), "Product on the line isn't the product in the PO line"
145
assert line.line_product_qty == 10.0, "The product qty of the line is different than the qty in the PO line"
146
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"
148
#assert line.line_confirmed_date == 1, ""
149
assert line.line_shipped_rate == 30.00, "Shipped rate on the followup is different than the shipped rate of the PO"
150
assert not line.move_product_id, "Product of the move is displayed"
151
assert line.move_product_qty == '7.00', "Product qty is not equal to 7.00"
152
assert not line.move_uom_id, "Product of the move is displayed"
153
assert line.move_state == 'Available', 'State of the move is incorrect in the followup line'
155
assert line.line_name == 1, "Line name is not equal to the name of the PO line"
156
assert not line.line_product_id.id, "Product of PO line is displayed in follow-up"
157
assert not line.line_product_qty, "The product qty of the line is different than the qty in the PO line"
158
assert not line.line_uom_id.id, "The UoM of the line is different than the UoM of the PO line"
160
#assert line.line_confirmed_date == 1, ""
161
assert line.line_shipped_rate == 'no-progressbar', "Shipped rate is displayed"
162
assert not line.move_product_id, "Product of the move is displayed"
163
assert line.move_product_qty == '3.00', "Product qty is not equal to 3.00"
164
assert not line.move_uom_id, "Product of the move is displayed"
165
assert line.move_state == 'Closed', 'State of the move is incorrect in the followup line (Closed :: %s)' % line.move_state
166
self.unlink(cr, uid, wiz_ids, context=context)