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