1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
-
I launch the comparison
-
!python {model: ir.actions.server}: |
context = {'active_id': ref('purchase_compare_rfq.rfq1'),
'active_ids': [ref('purchase_compare_rfq.rfq1'),ref('purchase_compare_rfq.rfq2'),ref('purchase_compare_rfq.rfq3'),]}
res = self.run(cr, uid, [ref('purchase_compare_rfq.action_compare_rfq')], context)
assert res != False, "Error on ir.actions.server launching"
-
I check the creation of the wizard
-
!python {model: wizard.compare.rfq}: |
assert len(self.search(cr, uid, [])) == 1, "Wrong number of created wizard"
-
I check if the wizard has three lines (one by product)
-
!python {model: wizard.compare.rfq.line}: |
assert len(self.search(cr, uid, [])) == 3, "Wrong number of created wizard lines"
assert len(self.search(cr, uid, [('product_id', '=', ref('product1'))])) == 1, "Wrong number of lines for P1"
assert len(self.search(cr, uid, [('product_id', '=', ref('product2'))])) == 1, "Wrong number of lines for P2"
assert len(self.search(cr, uid, [('product_id', '=', ref('product3'))])) == 1, "Wrong number of lines for P3"
-
I compare supplier's quotations for P1
-
!python {model: wizard.compare.rfq.line}: |
line_ids = self.search(cr, uid, [('product_id', '=', ref('product1'))])
assert len(line_ids) > 0, "No line found for P1"
if line_ids:
choose_line_obj = self.pool.get('wizard.choose.supplier.line')
choose_obj = self.pool.get('wizard.choose.supplier')
self.choose_supplier(cr, uid, line_ids[0])
-
I check if the wizard has well been created
-
!python {model: wizard.choose.supplier}: |
wiz_ids = self.search(cr, uid, [('product_id', '=', ref('product1'))])
assert len(wiz_ids) == 1, "Wrong number of wizard choose supplier for P1 (Result : %s)" %len(wiz_ids)
wiz = self.browse(cr, uid, wiz_ids[0])
assert len(wiz.line_ids) == 3, "Wrong number of choose supplier lines for P1 (Result : %s)" %len(wiz.line_ids)
-
I choose S1 for P1
-
!python {model: wizard.choose.supplier.line}: |
compare_line_obj = self.pool.get('wizard.compare.rfq.line')
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product1'))])
line_ids = self.search(cr, uid, [('compare_line_id', 'in', c_line_ids), ('supplier_id', '=', ref('supplier1'))])
if line_ids:
self.choose_supplier(cr, uid, line_ids[0])
assert len(compare_line_obj.search(cr, uid, [('product_id', '=', ref('product1'))])) == 1, "Wrong number of line for S1 for P1"
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product1'))])
for l in compare_line_obj.browse(cr, uid, c_line_ids):
assert l.supplier_id.id == ref('supplier1'), "Wrong supplier for P1"
-
I compare supplier's quotations for P2
-
!python {model: wizard.compare.rfq.line}: |
line_ids = self.search(cr, uid, [('product_id', '=', ref('product2'))])
assert len(line_ids) > 0, "No line found for P2"
if line_ids:
choose_line_obj = self.pool.get('wizard.choose.supplier.line')
choose_obj = self.pool.get('wizard.choose.supplier')
self.choose_supplier(cr, uid, line_ids[0])
-
I check if the wizard has well been created
-
!python {model: wizard.choose.supplier}: |
wiz_ids = self.search(cr, uid, [('product_id', '=', ref('product2'))])
assert len(wiz_ids) == 1, "Wrong number of wizard choose supplier for P2 (Result : %s)" %len(wiz_ids)
wiz = self.browse(cr, uid, wiz_ids[0])
assert len(wiz.line_ids) == 2, "Wrong number of choose supplier lines for P2 (Result : %s)" %len(wiz.line_ids)
-
I choose S1 for P2
-
!python {model: wizard.choose.supplier.line}: |
compare_line_obj = self.pool.get('wizard.compare.rfq.line')
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product2'))])
line_ids = self.search(cr, uid, [('compare_line_id', 'in', c_line_ids), ('supplier_id', '=', ref('supplier1'))])
if line_ids:
self.choose_supplier(cr, uid, line_ids[0])
assert len(compare_line_obj.search(cr, uid, [('product_id', '=', ref('product2'))])) == 1, "Wrong number of line for S1 for P2"
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product2'))])
for l in compare_line_obj.browse(cr, uid, c_line_ids):
assert l.supplier_id.id == ref('supplier1'), "Wrong supplier for P2"
-
I compare supplier's quotations for P3
-
!python {model: wizard.compare.rfq.line}: |
line_ids = self.search(cr, uid, [('product_id', '=', ref('product3'))])
assert len(line_ids) > 0, "No line found for P3"
if line_ids:
choose_line_obj = self.pool.get('wizard.choose.supplier.line')
choose_obj = self.pool.get('wizard.choose.supplier')
self.choose_supplier(cr, uid, line_ids[0])
-
I check if the wizard has well been created
-
!python {model: wizard.choose.supplier}: |
wiz_ids = self.search(cr, uid, [('product_id', '=', ref('product3'))])
assert len(wiz_ids) == 1, "Wrong number of wizard choose supplier for P3 (Result : %s)" %len(wiz_ids)
wiz = self.browse(cr, uid, wiz_ids[0])
assert len(wiz.line_ids) == 3, "Wrong number of choose supplier lines for P3 (Result : %s)" %len(wiz.line_ids)
-
I choose S1 for P3
-
!python {model: wizard.choose.supplier.line}: |
compare_line_obj = self.pool.get('wizard.compare.rfq.line')
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product3'))])
line_ids = self.search(cr, uid, [('compare_line_id', 'in', c_line_ids), ('supplier_id', '=', ref('supplier1'))])
if line_ids:
# Change the quantity to ten
self.write(cr, uid, [line_ids[0]], {'qty': 10})
self.choose_supplier(cr, uid, line_ids[0])
assert len(compare_line_obj.search(cr, uid, [('product_id', '=', ref('product3'))])) == 1, "Wrong number of line for S1 for P1"
c_line_ids = compare_line_obj.search(cr, uid, [('product_id', '=', ref('product3'))])
for l in compare_line_obj.browse(cr, uid, c_line_ids):
assert l.supplier_id.id == ref('supplier1'), "Wrong supplier for P1"
-
I confirm the PO creation
-
!python {model: wizard.compare.rfq}: |
wiz_id = self.search(cr, uid, [])[0]
self.create_po(cr, uid, wiz_id)
-
I check if only one PO has been created for this wizard
-
!python {model: purchase.order}: |
po_id = self.search(cr, uid, [('partner_id', '=', ref('supplier1'))])
assert len(po_id) == 1, "Wrong number of generated PO"
po = self.browse(cr, uid, po_id[0])
assert len(po.order_line) == 3, "Wrong number of lines on the PO for S1"
for line in po.order_line:
if line.product_id.id == ref('product1'):
assert line.price_unit == 1.30, "Wrong price unit for line with P1"
assert line.product_qty == 10, "Wrong quantity for line with P1"
elif line.product_id.id == ref('product2'):
assert line.price_unit == 1.75, "Wrong price unit for line with P2"
assert line.product_qty == 20, "Wrong quantity for line with P2"
elif line.product_id.id == ref('product3'):
assert line.price_unit == 2.17, "Wrong price unit for line with P3"
assert line.product_qty == 10, "Wrong quantity for line with P3"
else:
assert True == False, "Found line with product different of P1, P2 or P3"
-
I check if two other RfQ has been deleted
-
!python {model: purchase.order}: |
assert len(self.search(cr, uid, [('id', '=', ref('rfq2'))])) == 0, "RfQ 2 wasn't deleted"
assert len(self.search(cr, uid, [('id', '=', ref('rfq3'))])) == 0, "RfQ 2 wasn't deleted"
|