2
Tests of the splitting line wizard
4
We create a new UoM category
6
!record {model: product.uom.categ, id: split_uom_categ}:
11
!record {model: product.uom, id: split_uom}:
12
category_id: split_uom_categ
17
We create a new purchase order
19
!record {model: purchase.order, id: split_po}:
22
company_id: base.main_company
23
date_order: !eval time.strftime('%Y-%m-%d')
25
location_id: stock.stock_location_stock
26
partner_address_id: address1
27
pricelist_id: purchase.list0
29
We create a line for this purchase order
31
!record {model: purchase.order.line, id: split_pol}:
32
product_uom: split_uom
38
date_planned: !eval time.strftime('%Y-%m-%d')
40
Launch the split order line wizard
42
!record {model: split.purchase.order.line.wizard, id: split_wiz}:
43
purchase_line_id: split_pol
49
!python {model: split.purchase.order.line.wizard}: |
50
self.split_line(cr, uid, ref('split_wiz'), context=context)
52
Check if the PO has now 2 lines with the good quantities
54
!python {model: purchase.order.line}: |
55
lines = self.search(cr, uid, [('order_id', '=', ref('split_po'))], context=context)
56
assert len(lines) == 2, "The PO must have 2 lines after splitting, but it has %s lines !" % len(lines)
57
for l in self.browse(cr, uid, lines, context=context):
58
if l.product_qty != 297.95 and l.product_qty != 2.05:
59
assert False, "The quantities of PO lines are not correct"
61
Launch a second time the split order line wizard
63
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
64
purchase_line_id: split_pol
68
Check if the splitting method return an error
70
!python {model: split.purchase.order.line.wizard}: |
73
self.split_line(cr, uid, ref('split_wiz1'), context=context)
74
raise False, "No error raised when the new qty is equal to the original qty"
75
except osv.except_osv, e:
78
Change the new qty to have a new qty greater than the original qty
80
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
81
purchase_line_id: split_pol
85
Check if the splitting method return an error
87
!python {model: split.purchase.order.line.wizard}: |
90
self.split_line(cr, uid, ref('split_wiz1'), context=context)
91
raise False, "No error raised when the new qty is greater than the original qty"
92
except osv.except_osv, e:
95
Change the new qty to have a negative new qty
97
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
98
purchase_line_id: split_pol
102
Check if the splitting method return an error
104
!python {model: split.purchase.order.line.wizard}: |
107
self.split_line(cr, uid, ref('split_wiz1'), context=context)
108
raise False, "No error raised when the new qty is negative"
109
except osv.except_osv, e:
112
Change the new qty to have a new qty equal to 0.00
114
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
115
purchase_line_id: split_pol
119
Check if the splitting method return an error
121
!python {model: split.purchase.order.line.wizard}: |
124
self.split_line(cr, uid, ref('split_wiz1'), context=context)
125
raise False, "No error raised when the new qty is 0.00"
126
except osv.except_osv, e:
129
Change the new qty to have a new qty equal to 10.00
131
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
132
purchase_line_id: split_pol
136
Check if the splitting method return an error
138
!python {model: split.purchase.order.line.wizard}: |
141
self.split_line(cr, uid, ref('split_wiz1'), context=context)
142
except osv.except_osv, e:
143
raise False, "An error has been raised when the new qty is 10.00"