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 sale order
14
!record {model: sale.order, id: split_so}:
16
company_id: base.main_company
17
picking_policy: direct
18
invoice_quantity: order
19
partner_order_id: address1
20
partner_invoice_id: address1
21
partner_shipping_id: address1
23
pricelist_id: purchase.list0
26
We create a line for this sale order
28
!record {model: sale.order.line, id: split_sol}:
29
product_uom: split_uom
36
Launch the split order line wizard
38
!record {model: split.sale.order.line.wizard, id: split_wiz}:
39
sale_line_id: split_sol
45
!python {model: split.sale.order.line.wizard}: |
46
self.split_line(cr, uid, ref('split_wiz'), context=context)
48
Check if the SO has now 2 lines with the good quantities
50
!python {model: sale.order.line}: |
51
lines = self.search(cr, uid, [('order_id', '=', ref('split_so'))], context=context)
52
assert len(lines) == 2, "The SO must have 2 lines after splitting, but it has %s lines !" % len(lines)
53
for l in self.browse(cr, uid, lines, context=context):
54
if l.product_uom_qty != 297.95 and l.product_uom_qty != 2.05:
55
assert False, "The quantities of SO lines are not correct"
57
Launch a second time the split order line wizard
59
!record {model: split.sale.order.line.wizard, id: split_wiz1}:
60
sale_line_id: split_sol
64
Check if the splitting method return an error
66
!python {model: split.sale.order.line.wizard}: |
69
self.split_line(cr, uid, ref('split_wiz1'), context=context)
70
raise False, "No error raised when the new qty is equal to the original qty"
71
except osv.except_osv, e:
74
Change the new qty to have a new qty greater than the original qty
76
!record {model: split.sale.order.line.wizard, id: split_wiz1}:
77
sale_line_id: split_sol
81
Check if the splitting method return an error
83
!python {model: split.sale.order.line.wizard}: |
86
self.split_line(cr, uid, ref('split_wiz1'), context=context)
87
raise False, "No error raised when the new qty is greater than the original qty"
88
except osv.except_osv, e:
91
Change the new qty to have a negative new qty
93
!record {model: split.sale.order.line.wizard, id: split_wiz1}:
94
sale_line_id: split_sol
98
Check if the splitting method return an error
100
!python {model: split.sale.order.line.wizard}: |
103
self.split_line(cr, uid, ref('split_wiz1'), context=context)
104
raise False, "No error raised when the new qty is negative"
105
except osv.except_osv, e:
108
Change the new qty to have a new qty equal to 0.00
110
!record {model: split.sale.order.line.wizard, id: split_wiz1}:
111
sale_line_id: split_sol
115
Check if the splitting method return an error
117
!python {model: split.sale.order.line.wizard}: |
120
self.split_line(cr, uid, ref('split_wiz1'), context=context)
121
raise False, "No error raised when the new qty is 0.00"
122
except osv.except_osv, e:
125
Change the new qty to have a new qty equal to 10.00
127
!record {model: split.sale.order.line.wizard, id: split_wiz1}:
128
sale_line_id: split_sol
132
Check if the splitting method return an error
134
!python {model: split.sale.order.line.wizard}: |
137
self.split_line(cr, uid, ref('split_wiz1'), context=context)
138
except osv.except_osv, e:
139
raise False, "An error has been raised when the new qty is 10.00"