2
Tests of the splitting line wizard
6
!record {model: product.uom, id: split_uom}:
7
category_id: product.product_uom_categ_unit
12
We create a new purchase order
14
!record {model: purchase.order, id: split_po}:
17
company_id: base.main_company
18
date_order: !eval time.strftime('%Y-%m-%d')
20
location_id: stock.stock_location_stock
21
partner_address_id: address1
22
pricelist_id: purchase.list0
24
We create a line for this purchase order
26
!record {model: purchase.order.line, id: split_pol}:
27
product_uom: split_uom
33
date_planned: !eval time.strftime('%Y-%m-%d')
35
Launch the split order line wizard
37
!record {model: split.purchase.order.line.wizard, id: split_wiz}:
38
purchase_line_id: split_pol
44
!python {model: split.purchase.order.line.wizard}: |
45
self.split_line(cr, uid, ref('split_wiz'), context=context)
47
Check if the PO has now 2 lines with the good quantities
49
!python {model: purchase.order.line}: |
50
lines = self.search(cr, uid, [('order_id', '=', ref('split_po'))], context=context)
51
assert len(lines) == 2, "The PO must have 2 lines after splitting, but it has %s lines !" % len(lines)
52
for l in self.browse(cr, uid, lines, context=context):
53
if l.product_qty != 297.95 and l.product_qty != 2.05:
54
assert False, "The quantities of PO lines are not correct"
56
Launch a second time the split order line wizard
58
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
59
purchase_line_id: split_pol
63
Check if the splitting method return an error
65
!python {model: split.purchase.order.line.wizard}: |
68
self.split_line(cr, uid, ref('split_wiz1'), context=context)
69
raise False, "No error raised when the new qty is equal to the original qty"
70
except osv.except_osv, e:
73
Change the new qty to have a new qty greater than the original qty
75
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
76
purchase_line_id: split_pol
80
Check if the splitting method return an error
82
!python {model: split.purchase.order.line.wizard}: |
85
self.split_line(cr, uid, ref('split_wiz1'), context=context)
86
raise False, "No error raised when the new qty is greater than the original qty"
87
except osv.except_osv, e:
90
Change the new qty to have a negative new qty
92
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
93
purchase_line_id: split_pol
97
Check if the splitting method return an error
99
!python {model: split.purchase.order.line.wizard}: |
102
self.split_line(cr, uid, ref('split_wiz1'), context=context)
103
raise False, "No error raised when the new qty is negative"
104
except osv.except_osv, e:
107
Change the new qty to have a new qty equal to 0.00
109
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
110
purchase_line_id: split_pol
114
Check if the splitting method return an error
116
!python {model: split.purchase.order.line.wizard}: |
119
self.split_line(cr, uid, ref('split_wiz1'), context=context)
120
raise False, "No error raised when the new qty is 0.00"
121
except osv.except_osv, e:
124
Change the new qty to have a new qty equal to 10.00
126
!record {model: split.purchase.order.line.wizard, id: split_wiz1}:
127
purchase_line_id: split_pol
131
Check if the splitting method return an error
133
!python {model: split.purchase.order.line.wizard}: |
136
self.split_line(cr, uid, ref('split_wiz1'), context=context)
137
except osv.except_osv, e:
138
raise False, "An error has been raised when the new qty is 10.00"