2
I create empty theoretical composition list 06, kit_product_A, OOO, 2010-01-20
4
!record {model: composition.kit, id: kit_compo_06}:
5
composition_type: 'theoretical'
6
composition_product_id: kit_product_A
7
composition_version_txt: 'OOO'
8
composition_creation_date: '2010-01-20'
10
I then create Items for the compo 06 - prodC B
12
!record {model: composition.item, id: item_06_01}:
13
item_kit_id: kit_compo_06
14
item_product_id: kit_product_C
16
item_uom_id: product.product_uom_unit
18
!record {model: composition.item, id: item_06_02}:
19
item_kit_id: kit_compo_06
20
item_product_id: kit_product_B
22
item_uom_id: product.product_uom_unit
24
I set the theoretical kit 06 as complete and check corresponding states
26
!python {model: composition.kit}: |
27
self.mark_as_completed(cr, uid, [ref("kit_compo_06")], context=context)
28
kit = self.browse(cr, uid, ref("kit_compo_06"), context=context)
29
assert kit.state == 'completed', 'kit_compo_06: the field state is wrong, should be completed - %s'%kit.state
31
for item in kit.composition_item_ids:
32
assert item.state == 'completed', 'kit_compo_06: the field state of corresponding item is wrong, should be completed - %s'%item.state
34
I create a new kitting order for kit_product_A with kit_compo_06 as version
36
!record {model: kit.creation, id: kit_creation_01}:
37
product_id_kit_creation: kit_product_A
39
uom_id_kit_creation: product.product_uom_unit
40
version_id_kit_creation: kit_compo_06
41
location_dest_id_kit_creation: stock.stock_location_stock
42
default_location_src_id_kit_creation: stock.stock_location_stock
44
I check the display items from version function
46
!python {model: kit.creation}: |
47
self.do_reset_to_version(cr, uid, [ref("kit_creation_01")], context=context)
49
I check the good number of lines to consume are created
51
!python {model: kit.creation.to.consume}: |
52
ids_to_consume = self.search(cr, uid, [('kit_creation_id_to_consume', '=', ref("kit_creation_01"))], context=context)
53
assert len(ids_to_consume) == 2, 'kitting: the number of created lines to consume is wrong - 2 - %s'%len(ids_to_consume)
57
!python {model: kit.creation}: |
58
self.start_production(cr, uid, [ref("kit_creation_01")], context=context)
60
I check the internal picking is created
62
!python {model: kit.creation}: |
63
creation = self.browse(cr, uid, ref("kit_creation_01"), context=context)
64
assert creation.internal_picking_id_kit_creation.id, 'the internal picking for production is missing - %s'%creation.internal_picking_id_kit_creation.id
65
context.update({'internal_ids': [creation.internal_picking_id_kit_creation.id]})
67
I check 3 kits and corresponding batch number have been created
69
!python {model: composition.kit}: |
70
kit_ids = self.search(cr, uid, [('composition_kit_creation_id', '=', ref("kit_creation_01"))], context=context)
71
assert len(kit_ids) == 3, 'the number of produced kit is wrong - 3 - %s'%len(kit_ids)
72
for kit in self.browse(cr, uid, kit_ids, context=context):
73
assert kit.composition_lot_id.id, 'lot is missing for created kit - %s'%kit.composition_lot_id.id
74
context.update({'kit_ids': kit_ids})
76
I process with line button to consume kit_product_C (which needs LOT)
78
!python {model: kit.creation.to.consume}: |
79
to_consume_ids = self.search(cr, uid, [('kit_creation_id_to_consume', '=', ref("kit_creation_01")),('product_id_to_consume', '=', ref("kit_product_C"))], context=context)
80
assert len(to_consume_ids) == 1, 'the number of correponding to_consume lines is wrong - 1 - %s'%len(to_consume_ids)
81
context.update({'to_consume_idsC': to_consume_ids})
82
self.do_process_to_consume(cr, uid, to_consume_ids, context=dict(context))
84
I check a stock move has been created
86
!python {model: stock.move}: |
87
sm_ids = self.search(cr, uid, [('to_consume_id_stock_move', 'in', context['to_consume_idsC'])], context=context)
88
assert len(sm_ids) == 1, 'the number of created stock move is wrong - 1 - %s'%len(sm_ids)
89
context.update({'sm_idsC': sm_ids})
91
I get the to_consume id for productB
93
!python {model: kit.creation.to.consume}: |
94
to_consume_ids = self.search(cr, uid, [('kit_creation_id_to_consume', '=', ref("kit_creation_01")),('product_id_to_consume', '=', ref("kit_product_B"))], context=context)
95
assert len(to_consume_ids) == 1, 'the number of correponding to_consume lines is wrong - 1 - %s'%len(to_consume_ids)
96
context.update({'to_consume_idsB': to_consume_ids})
98
I process with all lines button
100
!python {model: kit.creation}: |
101
self.do_process_to_consume2(cr, uid, [ref("kit_creation_01")], context=dict(context))
103
I check a stock move has been created
105
!python {model: stock.move}: |
106
sm_ids = self.search(cr, uid, [('to_consume_id_stock_move', 'in', context['to_consume_idsB'])], context=context)
107
assert len(sm_ids) == 1, 'the number of created stock move is wrong - 1 - %s'%len(sm_ids)
108
context.update({'sm_idsB': sm_ids})
110
# I check the check Availability function - will be fully check with msf_outgoing implementation
112
# !python {model: kit.creation}: |
113
# self.check_availability(cr, uid, [ref("kit_creation_01")], context=dict(context))
115
I check the stock move
117
!python {model: stock.move}: |
118
sm_idsB = self.search(cr, uid, [('kit_creation_id_stock_move', '=', ref("kit_creation_01")),('product_id', '=', ref("kit_product_B"))], context=context)
119
sm_idsC = self.search(cr, uid, [('kit_creation_id_stock_move', '=', ref("kit_creation_01")),('product_id', '=', ref("kit_product_C"))], context=context)
120
assert len(sm_idsB) == 1, 'B the number of correponding stock move lines is wrong - 1 - %s'%len(sm_idsB)
121
assert len(sm_idsC) == 1, 'C the number of correponding stock move lines is wrong - 1 - %s'%len(sm_idsC)
122
context.update({'sm_idsB': sm_idsB, 'sm_idsC': sm_idsC})
124
I process the stock moves I set a prodlot
126
!python {model: stock.move}: |
127
self.write(cr, uid, context['sm_idsC'], {'prodlot_id': ref("kit_lot_Cs")}, context=context)
129
I force assign stock move
131
!python {model: stock.move}: |
132
self.force_assign(cr, uid, context['sm_idsB'] + context['sm_idsC'], context=context)
134
I force validate stock move
136
!python {model: stock.move}: |
137
self.validate_assign(cr, uid, context['sm_idsB'] + context['sm_idsC'], context=context)
139
I open the assign wizard
141
!python {model: stock.move}: |
142
res = self.assign_to_kit(cr, uid, context['sm_idsC'], context=context)
143
model = res['res_model']
146
context['wizard'] = {'id': id, 'ids': [id], 'model': model, 'c': c}
148
I distribute the quantity to the kits in the wizard
150
!python {model: assign.to.kit}: |
151
for obj in self.browse(cr, uid, context['wizard']['ids'], context=context['wizard']['c']):
152
for mem in obj.kit_ids_assign_to_kit:
153
mem.write({'assigned_qty_assign_to_kit_line': 10}, context=context['wizard']['c'])
154
self.do_assign_to_kit(cr, uid, context['wizard']['ids'], context=context['wizard']['c'])
156
I confirm the kitting
158
!python {model: kit.creation}: |
159
self.confirm_kitting(cr, uid, [ref("kit_creation_01")], context=context)
160
creation = self.browse(cr, uid, ref("kit_creation_01"), context=context)
161
assert creation.state == 'done', 'the kit creation object is not done - done %s'%creation.state
163
I check all kits are completed and with the correct items
165
!python {model: composition.kit}: |
166
kit_ids = context['kit_ids']
167
for kit in self.browse(cr, uid, kit_ids, context=context):
168
data = {'ProdB': 20, 'ProdC': 10}
169
assert kit.state == 'completed', 'state of the kit is wrong - completed - %s'%kit.state
170
for item in kit.composition_item_ids:
171
assert data[item.item_product_id.name] == item.item_qty, 'quantity for the selected product is wrong - %s - %s'%(data[item.item_product_id.name],item.item_qty)
172
data.pop(item.item_product_id.name)
173
assert not data.values(), 'all data have not been treated - [] - %s'%data.values()
175
I check the internal has 3 moves
177
!python {model: stock.picking}: |
178
for obj in self.browse(cr, uid, context['internal_ids'], context=context):
179
assert len(obj.move_lines) != 3, 'the number of stock moves is wrong - 3 - %s'%len(obj.move_lines)
183
!python {model: stock.picking}: |