6
from resourcing import ResourcingTest
9
class UF2507ResourcingTest(ResourcingTest):
11
def test_uf_2507(self):
13
1/ Create a field order with 4 lines and source all lines
15
2/ Delete the first line.
16
3/ Add a new line without origin set
17
4/ Set the origin on the new line
18
5/ Validate and confirm the PO
19
6/ Check the number of lines in the FO
24
c_wiz_model = 'purchase.order.line.unlink.wizard'
25
c_wiz = db.get(c_wiz_model)
28
1/ Create and source the first FO
30
order_id, order_line_ids, po_ids, po_line_ids = self.order_source_all_one_po(db)
32
# Check number of generated PO and PO lines
36
"Number of generated PO : %s - Should be 1" % len(po_ids),
41
"Number of lines generated in PO : %s - Should be 4" % len(po_line_ids),
45
2/ Delete the first line of the PO
47
c_res = self.pol_obj.ask_unlink(po_line_ids[0])
49
# Check display of cancel wizard
52
"No wizard returned by the cancellation of the PO line",
55
c_res.get('res_model') == c_wiz_model,
56
"The model returned by the cancellation of the PO line is not good",
59
c_wiz.just_cancel(c_res.get('res_id'))
61
# Check the PO line has been removed
62
po_line_ids = self.po_obj.read(po_ids[0], ['order_line'])['order_line']
64
len(po_line_ids) == 3,
65
"The line has not been removed well on the PO (%s - should be 3)" % len(po_line_ids),
67
# Check the FO line has been removed
69
self._get_number_of_valid_lines(db, order_id) == 3,
70
"The line has not been removed well on the FO",
74
3/ Add a new line without origin set
76
ana_distrib_id = self.pol_obj.read(po_line_ids[1], ['analytic_distribution_id'])['analytic_distribution_id']
77
if not ana_distrib_id:
78
ana_distrib_id = self.get_record(db, 'distrib_1')
80
ana_distrib_id = ana_distrib_id[0]
82
'order_id': po_ids[0],
83
'product_id': self.get_record(db, 'prod_log_1'),
84
'product_uom': self.get_record(db, 'product_uom_unit', module='product'),
87
'analytic_distribution_id': ana_distrib_id,
89
new_pol_id = self.pol_obj.create(line_values)
91
# Check the PO line has been added well
92
po_line_ids = self.po_obj.read(po_ids[0], ['order_line'])['order_line']
94
len(po_line_ids) == 4,
95
"Number of lines generated in PO : %s - Should be 4" % len(po_line_ids),
99
4/ Set the origin on the new line
101
order_name = self.order_obj.read(order_id, ['name'])['name']
102
self.pol_obj.write(new_pol_id, {'origin': order_name})
105
5/ Validate and confirm the PO
107
self._validate_po(db, po_ids)
108
self._confirm_po(db, po_ids)
112
6/ Check the number of lines in the FO/IR
114
# Check the FO line has been added
115
fo_lines_nb = self._get_number_of_valid_lines(db, order_id)
118
"The line has not been added well on the order (%s - should be 4)" % fo_lines_nb,
122
class UF2507FOResourcingTest(UF2507ResourcingTest):
126
super(UF2507FOResourcingTest, self).setUp()
129
class UF2507IRResourcingTest(UF2507ResourcingTest):
133
super(UF2507IRResourcingTest, self).setUp()
137
def get_test_suite():
138
'''Return the class to use for tests'''
139
return UF2507FOResourcingTest, UF2507IRResourcingTest
b'\\ No newline at end of file'