136 lines
4.9 KiB
YAML
136 lines
4.9 KiB
YAML
|
-
|
||
|
Create a new stockable product
|
||
|
-
|
||
|
!record {model: product.product, id: product_wise}:
|
||
|
name: Wise Unit
|
||
|
type: product
|
||
|
categ_id: product.product_category_1
|
||
|
uom_id: product.product_uom_unit
|
||
|
uom_po_id: product.product_uom_unit
|
||
|
-
|
||
|
Create an incoming picking for this product of 10 PCE from suppliers to stock
|
||
|
-
|
||
|
!record {model: stock.picking, id: pick1_wise}:
|
||
|
name: Incoming picking (wise unit)
|
||
|
partner_id: base.res_partner_2
|
||
|
picking_type_id: picking_type_in
|
||
|
move_lines:
|
||
|
- product_id: product_wise
|
||
|
product_uom_qty: 10.00
|
||
|
location_id: stock_location_suppliers
|
||
|
location_dest_id: stock_location_stock
|
||
|
-
|
||
|
Confirm and assign picking and prepare partial
|
||
|
-
|
||
|
!python {model: stock.picking, id: pick1_wise}: |
|
||
|
self.action_confirm()
|
||
|
self.do_prepare_partial()
|
||
|
-
|
||
|
Put 6 pieces in shelf1 and 4 pieces in shelf2
|
||
|
-
|
||
|
!python {model: stock.picking, id: pick1_wise}: |
|
||
|
stock_pack = self.env['stock.pack.operation']
|
||
|
stock_quant_pack = self.env['stock.quant.package']
|
||
|
package1 = stock_quant_pack.create({'name': 'Pack 1'})
|
||
|
self.pack_operation_ids[0].write({
|
||
|
'result_package_id': package1.id,
|
||
|
'product_qty': 4,
|
||
|
'location_dest_id': ref('stock_location_components')
|
||
|
})
|
||
|
new_pack1 = stock_pack.create({
|
||
|
'product_id': ref('product_wise'),
|
||
|
'product_uom_id': ref('product.product_uom_unit'),
|
||
|
'picking_id': ref('pick1_wise'),
|
||
|
'product_qty': 6.0,
|
||
|
'location_id': ref('stock_location_suppliers'),
|
||
|
'location_dest_id': ref('stock_location_14')
|
||
|
})
|
||
|
-
|
||
|
Transfer the receipt
|
||
|
-
|
||
|
!python {model: stock.picking, id: pick1_wise}: |
|
||
|
self.do_transfer()
|
||
|
-
|
||
|
Check the system created 2 quants
|
||
|
-
|
||
|
!python {model: stock.quant, id: False}: |
|
||
|
records = self.search([('product_id','=',ref('product_wise'))])
|
||
|
assert len(records.ids) == 2, "The number of quants created is not correct"
|
||
|
-
|
||
|
Make a delivery order of 5 pieces to the customer
|
||
|
-
|
||
|
!record {model: stock.picking, id: delivery_order_wise1}:
|
||
|
name: outgoing picking 1 (wise unit)
|
||
|
partner_id: base.res_partner_4
|
||
|
picking_type_id: stock.picking_type_out
|
||
|
move_lines:
|
||
|
- product_id: product_wise
|
||
|
product_uom_qty: 5.0
|
||
|
location_id: stock_location_stock
|
||
|
location_dest_id: stock_location_customers
|
||
|
-
|
||
|
Assign and confirm
|
||
|
-
|
||
|
!python {model: stock.picking, id: delivery_order_wise1}: |
|
||
|
self.action_confirm()
|
||
|
self.action_assign()
|
||
|
-
|
||
|
Make a delivery order of 5 pieces to the customer
|
||
|
-
|
||
|
!record {model: stock.picking, id: delivery_order_wise2}:
|
||
|
name: outgoing picking 2 (wise unit)
|
||
|
partner_id: base.res_partner_4
|
||
|
picking_type_id: stock.picking_type_out
|
||
|
move_lines:
|
||
|
- product_id: product_wise
|
||
|
product_uom_qty: 5.0
|
||
|
location_id: stock_location_stock
|
||
|
location_dest_id: stock_location_customers
|
||
|
-
|
||
|
Assign and confirm
|
||
|
-
|
||
|
!python {model: stock.picking, id: delivery_order_wise2}: |
|
||
|
self.action_confirm()
|
||
|
self.action_assign()
|
||
|
-
|
||
|
The operator is a wise guy and decides to do the opposite of what Odoo proposes. He uses the products reserved on picking 1 on picking 2 and vice versa
|
||
|
-
|
||
|
!python {model: stock.picking, id: False}: |
|
||
|
stock_pack = self.env['stock.pack.operation']
|
||
|
picking1 = self.browse(ref('delivery_order_wise1'))
|
||
|
picking2 = self.browse(ref('delivery_order_wise2'))
|
||
|
pack_ids1 = [x.id for x in picking1.pack_operation_ids]
|
||
|
pack_ids2 = [x.id for x in picking2.pack_operation_ids]
|
||
|
self.env['stock.pack.operation'].browse(pack_ids1).write({'picking_id': picking2.id})
|
||
|
self.env['stock.pack.operation'].browse(pack_ids2).write({'picking_id': picking1.id})
|
||
|
link_obj = self.env['stock.move.operation.link']
|
||
|
# The recompute remaining qtys does not take into account that pack operations change picking
|
||
|
links = link_obj.search([('operation_id', 'in', pack_ids1 + pack_ids2)])
|
||
|
links.unlink()
|
||
|
-
|
||
|
Process this picking
|
||
|
-
|
||
|
!python {model: stock.picking, id: delivery_order_wise1}: |
|
||
|
self.do_transfer()
|
||
|
-
|
||
|
Check there was no negative quant created by this picking
|
||
|
-
|
||
|
!python {model: stock.quant, id: False}: |
|
||
|
records = self.search([('product_id','=',ref('product_wise')), ('qty', '<', 0.0)])
|
||
|
assert len(records.ids) == 0, 'This should not have created a negative quant'
|
||
|
-
|
||
|
Check the other delivery order has changed its state back to partially available
|
||
|
-
|
||
|
!python {model: stock.picking, id: delivery_order_wise2}: |
|
||
|
assert self.state == 'partially_available', "Delivery order 2 should be back in confirmed state"
|
||
|
-
|
||
|
Process the second picking
|
||
|
-
|
||
|
!python {model: stock.picking, id: delivery_order_wise2}: |
|
||
|
self.do_transfer()
|
||
|
-
|
||
|
Check all quants are in Customers and there are no negative quants anymore
|
||
|
-
|
||
|
!python {model: stock.quant, id: False}: |
|
||
|
records = self.search([('product_id','=',ref('product_wise'))])
|
||
|
assert all([x.location_id.id==ref('stock_location_customers') and x.qty > 0.0 for x in records]), "Negative quant or wrong location detected"
|