[IMP] copywriting summary of modules
[odoo/odoo.git] / addons / stock / test / shipment.yml
1 -
2   I confirm outgoing shipment of 130 kgm Ice-cream.
3 -
4   !workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment}
5 -
6   I check shipment details after confirmed.
7 -
8   !python {model: stock.picking}: |
9     shipment = self.browse(cr, uid, ref("outgoing_shipment"))
10     assert shipment.state == "confirmed", "Shipment should be confirmed."
11     for move_line in shipment.move_lines:
12         assert move_line.state == "confirmed", "Move should be confirmed."
13
14 -
15   Now I check vitual stock of Ice-cream after confirmed outgoing shipment.
16 -
17   !python {model: product.product}: |
18     product = self.browse(cr, uid, ref('product_icecream'), context=context)
19     product.virtual_available == -30, "Vitual stock is not updated."
20
21 -
22   I confirm incomming shipment of 50 kgm Ice-cream.
23 -
24   !workflow {model: stock.picking, action: button_confirm, ref: incomming_shipment}
25 -
26   I receive 40kgm Ice-cream so I make backorder of incomming shipment for 40 kgm.
27 -
28   !python {model: stock.partial.picking}: |
29     context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]})
30 -
31   !record {model: stock.partial.picking, id: partial_incomming}:
32     move_ids:
33         - quantity: 40
34           product_id: product_icecream
35           product_uom: product.product_uom_kgm
36           move_id: incomming_shipment_icecream
37           location_id: location_convenience_shop
38           location_dest_id: location_refrigerator
39 -
40   !python {model: stock.partial.picking }: |
41     self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
42 -
43   I check backorder shipment after received partial shipment.
44 -
45   !python {model: stock.picking}: |
46     shipment = self.browse(cr, uid, ref("incomming_shipment"))
47     backorder = shipment.backorder_id
48     assert backorder, "Backorder should be created after partial shipment."
49     assert backorder.state == 'done', "Backorder should be close after received."
50     for move_line in backorder.move_lines:
51         assert move_line.product_qty == 40, "Qty in backorder does not correspond."
52         assert move_line.state == 'done', "Move line of backorder should be closed."
53 -
54   I receive another 10kgm Ice-cream.
55 -
56   !record {model: stock.partial.picking, id: partial_incomming}:
57     move_ids:
58         - quantity: 10
59           product_id: product_icecream
60           product_uom: product.product_uom_kgm
61           move_id: incomming_shipment_icecream
62           location_id: location_convenience_shop
63           location_dest_id: location_refrigerator
64 -
65   !python {model: stock.partial.picking }: |
66     self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
67
68 -
69   I check incomming shipment after received.
70 -
71   !python {model: stock.picking}: |
72     shipment = self.browse(cr, uid, ref("incomming_shipment"))
73     assert shipment.state == 'done', "shipment should be close after received."
74     for move_line in shipment.move_lines:
75         assert move_line.product_qty == 10, "Qty does not correspond."
76         assert move_line.product_id.virtual_available == 20, "Virtual stock does not correspond."
77         assert move_line.state == 'done', "Move line should be closed."
78
79 -
80   I return last incomming shipment for 10 kgm Ice-cream.
81 -
82   !record {model: stock.return.picking, id: return_incomming}:
83     invoice_state: none
84 -
85   !python {model: stock.return.picking }: |
86     # this work without giving the id of the picking to return, magically, thanks to the context
87     self.create_returns(cr, uid, [ref('return_incomming')], context=context)
88 -
89   I cancel incomming shipment after return it.
90 -
91   !python {model: stock.picking}: |
92     # the cancel is not on the return, but on the incomming shipment (which now has a quantity of 10, thanks to the 
93     # backorder). This situation is a little weird as we returned a move that we finally cancelled... As result, only
94     # 30Kg from the original 50Kg will be counted in the stock (50 - 10 (cancelled quantity) - 10 (returned quantity))
95     self.action_cancel(cr, uid, [ref("incomming_shipment")], context=context)
96 -
97   I make invoice of backorder of incomming shipment.
98 -
99   !python {model: stock.invoice.onshipping}: |
100     shipment = self.pool.get('stock.picking').browse(cr, uid, ref("incomming_shipment"))
101     context.update({'active_model': 'stock.picking', 'active_id': shipment.backorder_id.id, 'active_ids': [shipment.backorder_id.id]})
102 -
103   !record {model: stock.invoice.onshipping, id: invoice_incomming}:
104     group: False
105 -
106   !python {model: stock.invoice.onshipping }: |
107     self.create_invoice(cr, uid, [ref('invoice_incomming')], context=context)
108 -
109   I check invoice state of backorder of incomming shipment.
110 -
111   !python {model: stock.picking}: |
112     shipment = self.browse(cr, uid, ref("incomming_shipment"))
113     assert shipment.backorder_id.invoice_state == 'invoiced', 'Invoice state is not upadted.'
114 -
115   I check available stock after received incomming shipping.
116 -
117   !python {model: product.product}: |
118     product = self.browse(cr, uid, ref('product_icecream'), context=context)
119     assert product.qty_available == 140, "Stock does not correspond."
120     assert product.virtual_available == 0, "Vitual stock does not correspond."
121 -
122   I split incomming shipment into lots. each lot contain 10 kgm Ice-cream.
123 -
124   !python {model: stock.picking}: |
125     shipment = self.browse(cr, uid, ref("incomming_shipment"))
126     move_ids = [x.id for x in shipment.backorder_id.move_lines]
127     context.update({'active_model': 'stock.move', 'active_id': move_ids[0], 'active_ids': move_ids})
128 -
129   !record {model: stock.move.split, id: split_lot_incomming}:
130     line_ids:
131         - name: incoming_lot0
132           quantity: 10
133         - name: incoming_lot1
134           quantity: 10
135         - name: incoming_lot2
136           quantity: 10
137         - name: incoming_lot3
138           quantity: 10
139         
140 -
141  !python {model: stock.move.split }: |
142     self.split_lot(cr, uid, [ref('split_lot_incomming')], context=context)
143 -
144   I check move lines after spliting
145 -
146   !python {model: stock.move}: |
147     lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context)
148     lot_ids = self.pool.get('stock.production.lot').search(cr, uid, [('name','in',[x.name for x in lot.line_ids])])
149     assert len(lot_ids) == 4, 'lots of incomming shipment are not correspond.'
150     move_ids = self.search(cr, uid, [('location_dest_id','=',ref('location_refrigerator')),('prodlot_id','in',lot_ids)])
151     assert len(move_ids) == 4, 'move lines are not correspond per prodcution lot after splited.'
152     for move in self.browse(cr, uid, move_ids, context=context):
153         assert move.prodlot_id.name in ['incoming_lot0', 'incoming_lot1', 'incoming_lot2', 'incoming_lot3'], "lot does not correspond." 
154         assert move.product_qty == 10, "qty does not correspond per production lot."
155     context.update({'active_model':'stock.move', 'active_id':move_ids[0],'active_ids': move_ids})
156 -
157   I check the stock valuation account entries.
158 -
159   !python {model: account.move}: |
160     incomming_shipment = self.pool.get('stock.picking').browse(cr, uid, ref('incomming_shipment'), context=context)
161     account_move_ids = self.search(cr, uid, [('ref','=',incomming_shipment.name)])
162     assert len(account_move_ids), "account move should be created."
163     account_move = self.browse(cr, uid, account_move_ids[0], context=context)
164     assert len(account_move.line_id) == len(incomming_shipment.move_lines) + 1, 'accuont entries are not correspond.'
165     for account_move_line in account_move.line_id:
166         for stock_move in incomming_shipment.move_lines:
167             if account_move_line.account_id.id == stock_move.product_id.property_stock_account_input.id:
168                 assert account_move_line.credit == 800.0, "Credit amount does not correspond."
169                 assert account_move_line.debit == 0.0, "Debit amount does not correspond."
170             else:
171                 assert account_move_line.credit == 0.0, "Credit amount does not correspond."
172                 assert account_move_line.debit == 800.0, "Debit amount does not correspond."
173 -
174   I consume 1 kgm ice-cream from each incoming lots into internal production.
175 -
176   !record {model: stock.move.consume, id: consume_lot_incomming}:
177     product_qty: 1
178     location_id: location_refrigerator
179 -
180   !python {model: stock.move.consume}: |
181     self.do_move_consume(cr, uid, [ref('consume_lot_incomming')], context=context)
182 -
183   I scrap 10 gm ice-cream from each incoming lots into scrap location.
184 -
185   !record {model: stock.move.scrap, id: scrap_lot_incomming}:
186     product_qty: 0.010
187 -
188   !python {model: stock.move.scrap}: |
189     self.move_scrap(cr, uid, [ref('scrap_lot_incomming')], context=context)
190 -
191   I check stock in scrap location and refrigerator location.
192 -
193   !python {model: stock.location}: |
194     ctx = {'product_id': ref('product_icecream')}
195     refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_refrigerator'), context=ctx)
196     assert refrigerator_location.stock_real == 135.96, 'stock does not correspond in refrigerator location.'
197     scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx)
198     assert scrapped_location.stock_real == 0.010*4, 'scraped stock does not correspond in scrap location.'
199     
200 -
201   I check availabile stock after consumed and scraped.
202 -
203   !python {model: product.product}: |
204     product = self.browse(cr, uid, ref('product_icecream'), context=context)
205     assert product.qty_available == 135.96, "Stock does not correspond."
206     assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond."
207 -
208   I trace all incoming lots.
209 -
210   !python {model: stock.production.lot }: |
211     lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context)
212     lot_ids = self.search(cr, uid, [('name', 'in', [x.name for x in lot.line_ids])])
213     self.action_traceability(cr, uid, lot_ids, context=context)
214 -
215   I check outgoing shipment after stock availablity in refrigerator.
216 -
217   !python {model: stock.picking}: |
218     shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context)
219     self.pool.get('stock.move').action_assign(cr, uid, [x.id for x in shipment.move_lines]) #TOFIX: assignment of move lines should be call before testing assigment otherwise picking never gone in assign state
220     #TOFIX: shipment should be assigned if stock available
221     #assert shipment.state == "assigned", "Shipment should be assigned."
222     #for move_line in shipment.move_lines:
223     #    assert move_line.state == "assigned", "Move should be assigned."
224     self.force_assign(cr, uid, [shipment.id])
225 -
226   I deliver 5kgm Ice-cream to customer so I make partial deliver
227 -
228   !python {model: stock.partial.move}: |
229     context.update({'active_model': 'stock.move', 'active_id': ref('outgoing_shipment_icecream'), 'active_ids': [ref('outgoing_shipment_icecream')]})
230 -
231   !record {model: stock.partial.move, id: partial_outgoing_icecream}:
232     move_ids:
233         - quantity: 5
234           product_id: product_icecream
235           product_uom: product.product_uom_kgm
236           move_id: outgoing_shipment_icecream
237           location_id: location_refrigerator
238           location_dest_id: location_delivery_counter
239 -
240   !python {model: stock.partial.move }: |
241     self.do_partial(cr, uid, [ref('partial_outgoing_icecream')], context=context)
242
243 -
244   I packing outgoing shipment into box per 10kgm with unique tracking lot.
245 -
246   !python {model: stock.move}: |
247     stock_split = self.pool.get('stock.split.into')
248     move = self.browse(cr, uid, ref('outgoing_shipment_icecream'), context=context)
249     context.update({'active_model': 'stock.move', 'active_id': move.id, 'active_ids': [move.id]})
250     total_qty = move.product_qty
251     split_qty = 10
252     while(total_qty>0):
253         split_id = stock_split.create(cr, uid, {'quantity': split_qty}, context=context)
254         stock_split.split(cr, uid, [split_id], context=context)
255         total_qty -= split_qty
256 -
257   I deliver outgoing shipment.
258 -
259   !python {model: stock.partial.picking}: |
260     context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]})
261 -
262   !record {model: stock.partial.picking, id: partial_outgoing}:
263     picking_id: outgoing_shipment
264 -
265   !python {model: stock.partial.picking }: |
266     self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
267
268 -
269   I check outgoing shipment after deliver.
270 -
271   !python {model: stock.picking}: |
272     shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context)
273     assert shipment.state == "done", "Shipment should be closed."
274     for move_line in shipment.move_lines:
275         assert move_line.state == "done", "Move should be closed."
276 -
277   I check availaible stock after deliver.
278 -
279   !python {model: product.product}: |
280     product = self.browse(cr, uid, ref('product_icecream'), context=context)
281     assert round(product.qty_available, 2) == 5.96, "Stock does not correspond."
282     assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond."