mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[add] tests
This commit is contained in:
@@ -36,6 +36,9 @@ This module extends standard stock valuation (based on products). Valuing lots a
|
||||
"stock_view.xml",
|
||||
],
|
||||
"demo" : [],
|
||||
'test': [
|
||||
'test/opening_stock.yml',
|
||||
],
|
||||
"active": False,
|
||||
"installable": True
|
||||
}
|
||||
|
||||
@@ -26,8 +26,13 @@ class stock_production_lot(orm.Model):
|
||||
_inherit = "stock.production.lot"
|
||||
|
||||
_columns = {
|
||||
'standard_price': fields.float('Cost', digits_compute=dp.get_precision('Lot Price'), help="Cost price (in company currency) of the lot used for standard stock valuation in accounting.", groups="base.group_user"),
|
||||
'cost_method': fields.selection([('standard','Standard Price'), ('average','Average Price')], 'Costing Method', required=True,
|
||||
'standard_price': fields.float('Cost', digits_compute=dp.get_precision('Lot Price'),
|
||||
help="Cost price (in company currency) of the lot used for standard stock valuation in accounting.",
|
||||
groups="base.group_user"),
|
||||
'cost_method': fields.selection([
|
||||
('standard','Standard Price'),
|
||||
('average','Average Price')
|
||||
], 'Costing Method',
|
||||
help="Standard Price: The cost price is manually updated at the end of a specific period. \nAverage Price: The cost price is recomputed at each incoming shipment."),
|
||||
}
|
||||
|
||||
|
||||
193
stock_lot_valuation/test/opening_stock.yml
Normal file
193
stock_lot_valuation/test/opening_stock.yml
Normal file
@@ -0,0 +1,193 @@
|
||||
-
|
||||
!record {model: stock.location, id: location_refrigerator}:
|
||||
name: Refrigerator
|
||||
usage: internal
|
||||
-
|
||||
!record {model: stock.location, id: location_delivery_counter}:
|
||||
name: Delivery Counter
|
||||
usage: internal
|
||||
-
|
||||
!record {model: stock.location, id: location_refrigerator_small}:
|
||||
name: Small Refrigerator
|
||||
usage: internal
|
||||
location_id: location_refrigerator
|
||||
-
|
||||
!record {model: stock.location, id: location_opening}:
|
||||
name: opening
|
||||
usage: inventory
|
||||
-
|
||||
!record {model: stock.location, id: location_convenience_shop}:
|
||||
name: Convenient Store
|
||||
usage: supplier
|
||||
-
|
||||
!record {model: stock.warehouse, id: warehouse_icecream}:
|
||||
name: Ice Cream Shop
|
||||
lot_input_id: location_refrigerator
|
||||
lot_stock_id: location_refrigerator
|
||||
lot_output_id: location_delivery_counter
|
||||
-
|
||||
!record {model: product.product, id: product_icecream}:
|
||||
default_code: 001
|
||||
name: Ice Cream
|
||||
type: product
|
||||
categ_id: product.product_category_1
|
||||
list_price: 100.0
|
||||
standard_price: 70.0
|
||||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
procure_method: make_to_stock
|
||||
property_stock_inventory: location_opening
|
||||
valuation: real_time
|
||||
cost_method: average
|
||||
property_stock_account_input: account.o_expense
|
||||
property_stock_account_output: account.o_income
|
||||
description: Ice cream can be mass-produced and thus is widely available in developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds) from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience stores, and milk bars, and in individual servings from small carts or vans at public events.
|
||||
lot_valuation: True
|
||||
|
||||
-
|
||||
!record {model: stock.production.lot, id: lot_icecream_0}:
|
||||
name: Lot0 for Ice cream
|
||||
product_id: product_icecream
|
||||
cost_method: average
|
||||
-
|
||||
!record {model: stock.production.lot, id: lot_icecream_1}:
|
||||
name: Lot1 for Ice cream
|
||||
product_id: product_icecream
|
||||
-
|
||||
!record {model: stock.inventory, id: stock_inventory_icecream}:
|
||||
name: Inventory for icecream
|
||||
-
|
||||
!record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot0}:
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
inventory_id: stock_inventory_icecream
|
||||
product_qty: 50.0
|
||||
prod_lot_id: lot_icecream_0
|
||||
location_id: location_refrigerator
|
||||
-
|
||||
!record {model: stock.inventory.line, id: stock_inventory_line_icecream_lot1}:
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
inventory_id: stock_inventory_icecream
|
||||
product_qty: 40.0
|
||||
prod_lot_id: lot_icecream_1
|
||||
location_id: location_refrigerator
|
||||
|
||||
-
|
||||
!record {model: stock.picking, id: outgoing_shipment}:
|
||||
type: out
|
||||
location_dest_id: location_delivery_counter
|
||||
-
|
||||
!record {model: stock.move, id: outgoing_shipment_icecream}:
|
||||
picking_id: outgoing_shipment
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
product_qty: 130.0
|
||||
location_id: location_refrigerator
|
||||
location_dest_id: location_delivery_counter
|
||||
-
|
||||
!record {model: stock.picking, id: incomming_shipment}:
|
||||
type: in
|
||||
invoice_state: 2binvoiced
|
||||
partner_id: base.res_partner_address_9
|
||||
location_dest_id: location_refrigerator
|
||||
-
|
||||
!record {model: stock.move, id: incomming_shipment_icecream}:
|
||||
picking_id: incomming_shipment
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
product_qty: 50.0
|
||||
location_id: location_convenience_shop
|
||||
location_dest_id: location_refrigerator
|
||||
|
||||
-
|
||||
I update the price of the Ice-cream.
|
||||
-
|
||||
!python {model: stock.change.standard.price}: |
|
||||
context.update({'active_model':'product.product', 'active_id': ref('product_icecream'), 'active_ids':[ref('product_icecream')]})
|
||||
-
|
||||
!record {model: stock.change.standard.price, id: change_price}:
|
||||
new_price: 120
|
||||
-
|
||||
!python {model: stock.change.standard.price}: |
|
||||
self.change_price(cr, uid, [ref('change_price')], context=context)
|
||||
-
|
||||
I check price of Ice-cream after update price.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
assert product.standard_price == 120, "Price is not updated."
|
||||
|
||||
-
|
||||
I confirm physical inventory of Ice-cream which are came in different lots.
|
||||
-
|
||||
!python {model: stock.inventory}: |
|
||||
self.action_confirm(cr, uid, [ref('stock_inventory_icecream')], context=context)
|
||||
-
|
||||
I check move details after confirmed physical inventory.
|
||||
-
|
||||
!python {model: stock.inventory}: |
|
||||
inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context)
|
||||
assert len(inventory.move_ids) == len(inventory.inventory_line_id), "moves are not correspond."
|
||||
for move_line in inventory.move_ids:
|
||||
for line in inventory.inventory_line_id:
|
||||
if move_line.product_id.id == line.product_id.id and move_line.prodlot_id.id == line.prod_lot_id.id:
|
||||
location_id = line.product_id.property_stock_inventory.id
|
||||
assert move_line.product_qty == line.product_qty, "Qty is not correspond."
|
||||
assert move_line.product_uom.id == line.product_uom.id, "UOM is not correspond."
|
||||
assert move_line.date == inventory.date, "Date is not correspond."
|
||||
assert move_line.location_id.id == location_id, "Source location is not correspond."
|
||||
assert move_line.location_dest_id.id == line.location_id.id, "Destination location is not correspond."
|
||||
assert move_line.state == 'confirmed', "Move is not confirmed."
|
||||
-
|
||||
I split inventory line.
|
||||
-
|
||||
!python {model: stock.inventory.line.split}: |
|
||||
context.update({'active_model': 'stock.inventory.line', 'active_id': ref('stock_inventory_line_icecream_lot0'), 'active_ids': [ref('stock_inventory_line_icecream_lot0')]})
|
||||
-
|
||||
!record {model: stock.inventory.line.split, id: split_inventory_lot0}:
|
||||
use_exist: True
|
||||
line_exist_ids:
|
||||
- quantity: 6
|
||||
prodlot_id: lot_icecream_0
|
||||
- quantity: 4
|
||||
prodlot_id: lot_icecream_0
|
||||
-
|
||||
!python {model: stock.inventory.line.split }: |
|
||||
self.split_lot(cr, uid, [ref('split_inventory_lot0')], context=context)
|
||||
-
|
||||
I fill inventory line.
|
||||
-
|
||||
!python {model: stock.fill.inventory}: |
|
||||
context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]})
|
||||
-
|
||||
!record {model: stock.fill.inventory, id: fill_inventory}:
|
||||
location_id: location_refrigerator
|
||||
recursive: True
|
||||
-
|
||||
!python {model: stock.fill.inventory }: |
|
||||
self.fill_inventory(cr, uid, [ref('fill_inventory')], context=context)
|
||||
|
||||
-
|
||||
Now I check vitual stock of Ice-cream after confirmed physical inventory.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
assert product.virtual_available == 100, "Vitual stock is not updated."
|
||||
-
|
||||
I update the price of the Ice-cream lot.
|
||||
-
|
||||
!python {model: lot.change.standard.price}: |
|
||||
context.update({'active_model':'stock.production.lot', 'active_id': ref('lot_icecream_0'), 'active_ids':[ref('lot_icecream_0')]})
|
||||
-
|
||||
!record {model: lot.change.standard.price, id: change_price}:
|
||||
new_price: 120
|
||||
-
|
||||
!python {model: lot.change.standard.price}: |
|
||||
self.change_price(cr, uid, [ref('change_price')], context=context)
|
||||
-
|
||||
I check price of Ice-cream lot after update price.
|
||||
-
|
||||
!python {model: stock.production.lot}: |
|
||||
lot = self.browse(cr, uid, ref('lot_icecream_0'), context=context)
|
||||
assert lot.standard_price == 120, "Price is not updated."
|
||||
282
stock_lot_valuation/test/shipment.yml
Normal file
282
stock_lot_valuation/test/shipment.yml
Normal file
@@ -0,0 +1,282 @@
|
||||
-
|
||||
I confirm outgoing shipment of 130 kgm Ice-cream.
|
||||
-
|
||||
!workflow {model: stock.picking, action: button_confirm, ref: outgoing_shipment}
|
||||
-
|
||||
I check shipment details after confirmed.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("outgoing_shipment"))
|
||||
assert shipment.state == "confirmed", "Shipment should be confirmed."
|
||||
for move_line in shipment.move_lines:
|
||||
assert move_line.state == "confirmed", "Move should be confirmed."
|
||||
|
||||
-
|
||||
Now I check vitual stock of Ice-cream after confirmed outgoing shipment.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
product.virtual_available == -30, "Vitual stock is not updated."
|
||||
|
||||
-
|
||||
I confirm incomming shipment of 50 kgm Ice-cream.
|
||||
-
|
||||
!workflow {model: stock.picking, action: button_confirm, ref: incomming_shipment}
|
||||
-
|
||||
I receive 40kgm Ice-cream so I make backorder of incomming shipment for 40 kgm.
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
context.update({'active_model': 'stock.picking', 'active_id': ref('incomming_shipment'), 'active_ids': [ref('incomming_shipment')]})
|
||||
-
|
||||
!record {model: stock.partial.picking, id: partial_incomming}:
|
||||
move_ids:
|
||||
- quantity: 40
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
move_id: incomming_shipment_icecream
|
||||
location_id: location_convenience_shop
|
||||
location_dest_id: location_refrigerator
|
||||
-
|
||||
!python {model: stock.partial.picking }: |
|
||||
self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
|
||||
-
|
||||
I check backorder shipment after received partial shipment.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("incomming_shipment"))
|
||||
backorder = shipment.backorder_id
|
||||
assert backorder, "Backorder should be created after partial shipment."
|
||||
assert backorder.state == 'done', "Backorder should be close after received."
|
||||
for move_line in backorder.move_lines:
|
||||
assert move_line.product_qty == 40, "Qty in backorder does not correspond."
|
||||
assert move_line.state == 'done', "Move line of backorder should be closed."
|
||||
-
|
||||
I receive another 10kgm Ice-cream.
|
||||
-
|
||||
!record {model: stock.partial.picking, id: partial_incomming}:
|
||||
move_ids:
|
||||
- quantity: 10
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
move_id: incomming_shipment_icecream
|
||||
location_id: location_convenience_shop
|
||||
location_dest_id: location_refrigerator
|
||||
-
|
||||
!python {model: stock.partial.picking }: |
|
||||
self.do_partial(cr, uid, [ref('partial_incomming')], context=context)
|
||||
|
||||
-
|
||||
I check incomming shipment after received.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("incomming_shipment"))
|
||||
assert shipment.state == 'done', "shipment should be close after received."
|
||||
for move_line in shipment.move_lines:
|
||||
assert move_line.product_qty == 10, "Qty does not correspond."
|
||||
assert move_line.product_id.virtual_available == 20, "Virtual stock does not correspond."
|
||||
assert move_line.state == 'done', "Move line should be closed."
|
||||
|
||||
-
|
||||
I return last incomming shipment for 10 kgm Ice-cream.
|
||||
-
|
||||
!record {model: stock.return.picking, id: return_incomming}:
|
||||
invoice_state: none
|
||||
-
|
||||
!python {model: stock.return.picking }: |
|
||||
# this work without giving the id of the picking to return, magically, thanks to the context
|
||||
self.create_returns(cr, uid, [ref('return_incomming')], context=context)
|
||||
-
|
||||
I cancel incomming shipment after return it.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
# the cancel is not on the return, but on the incomming shipment (which now has a quantity of 10, thanks to the
|
||||
# backorder). This situation is a little weird as we returned a move that we finally cancelled... As result, only
|
||||
# 30Kg from the original 50Kg will be counted in the stock (50 - 10 (cancelled quantity) - 10 (returned quantity))
|
||||
self.action_cancel(cr, uid, [ref("incomming_shipment")], context=context)
|
||||
-
|
||||
I make invoice of backorder of incomming shipment.
|
||||
-
|
||||
!python {model: stock.invoice.onshipping}: |
|
||||
shipment = self.pool.get('stock.picking').browse(cr, uid, ref("incomming_shipment"))
|
||||
context.update({'active_model': 'stock.picking', 'active_id': shipment.backorder_id.id, 'active_ids': [shipment.backorder_id.id]})
|
||||
-
|
||||
!record {model: stock.invoice.onshipping, id: invoice_incomming}:
|
||||
group: False
|
||||
-
|
||||
!python {model: stock.invoice.onshipping }: |
|
||||
self.create_invoice(cr, uid, [ref('invoice_incomming')], context=context)
|
||||
-
|
||||
I check invoice state of backorder of incomming shipment.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("incomming_shipment"))
|
||||
assert shipment.backorder_id.invoice_state == 'invoiced', 'Invoice state is not upadted.'
|
||||
-
|
||||
I check available stock after received incomming shipping.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
assert product.qty_available == 140, "Stock does not correspond."
|
||||
assert product.virtual_available == 0, "Vitual stock does not correspond."
|
||||
-
|
||||
I split incomming shipment into lots. each lot contain 10 kgm Ice-cream.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("incomming_shipment"))
|
||||
move_ids = [x.id for x in shipment.backorder_id.move_lines]
|
||||
context.update({'active_model': 'stock.move', 'active_id': move_ids[0], 'active_ids': move_ids})
|
||||
-
|
||||
!record {model: stock.move.split, id: split_lot_incomming}:
|
||||
line_ids:
|
||||
- name: incoming_lot0
|
||||
quantity: 10
|
||||
- name: incoming_lot1
|
||||
quantity: 10
|
||||
- name: incoming_lot2
|
||||
quantity: 10
|
||||
- name: incoming_lot3
|
||||
quantity: 10
|
||||
|
||||
-
|
||||
!python {model: stock.move.split }: |
|
||||
self.split_lot(cr, uid, [ref('split_lot_incomming')], context=context)
|
||||
-
|
||||
I check move lines after spliting
|
||||
-
|
||||
!python {model: stock.move}: |
|
||||
lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context)
|
||||
lot_ids = self.pool.get('stock.production.lot').search(cr, uid, [('name','in',[x.name for x in lot.line_ids])])
|
||||
assert len(lot_ids) == 4, 'lots of incomming shipment are not correspond.'
|
||||
move_ids = self.search(cr, uid, [('location_dest_id','=',ref('location_refrigerator')),('prodlot_id','in',lot_ids)])
|
||||
assert len(move_ids) == 4, 'move lines are not correspond per prodcution lot after splited.'
|
||||
for move in self.browse(cr, uid, move_ids, context=context):
|
||||
assert move.prodlot_id.name in ['incoming_lot0', 'incoming_lot1', 'incoming_lot2', 'incoming_lot3'], "lot does not correspond."
|
||||
assert move.product_qty == 10, "qty does not correspond per production lot."
|
||||
context.update({'active_model':'stock.move', 'active_id':move_ids[0],'active_ids': move_ids})
|
||||
-
|
||||
I check the stock valuation account entries.
|
||||
-
|
||||
!python {model: account.move}: |
|
||||
incomming_shipment = self.pool.get('stock.picking').browse(cr, uid, ref('incomming_shipment'), context=context)
|
||||
account_move_ids = self.search(cr, uid, [('ref','=',incomming_shipment.name)])
|
||||
assert len(account_move_ids), "account move should be created."
|
||||
account_move = self.browse(cr, uid, account_move_ids[0], context=context)
|
||||
assert len(account_move.line_id) == len(incomming_shipment.move_lines) + 1, 'accuont entries are not correspond.'
|
||||
for account_move_line in account_move.line_id:
|
||||
for stock_move in incomming_shipment.move_lines:
|
||||
if account_move_line.account_id.id == stock_move.product_id.property_stock_account_input.id:
|
||||
assert account_move_line.credit == 800.0, "Credit amount does not correspond."
|
||||
assert account_move_line.debit == 0.0, "Debit amount does not correspond."
|
||||
else:
|
||||
assert account_move_line.credit == 0.0, "Credit amount does not correspond."
|
||||
assert account_move_line.debit == 800.0, "Debit amount does not correspond."
|
||||
-
|
||||
I consume 1 kgm ice-cream from each incoming lots into internal production.
|
||||
-
|
||||
!record {model: stock.move.consume, id: consume_lot_incomming}:
|
||||
product_qty: 1
|
||||
location_id: location_refrigerator
|
||||
-
|
||||
!python {model: stock.move.consume}: |
|
||||
self.do_move_consume(cr, uid, [ref('consume_lot_incomming')], context=context)
|
||||
-
|
||||
I scrap 10 gm ice-cream from each incoming lots into scrap location.
|
||||
-
|
||||
!record {model: stock.move.scrap, id: scrap_lot_incomming}:
|
||||
product_qty: 0.010
|
||||
-
|
||||
!python {model: stock.move.scrap}: |
|
||||
self.move_scrap(cr, uid, [ref('scrap_lot_incomming')], context=context)
|
||||
-
|
||||
I check stock in scrap location and refrigerator location.
|
||||
-
|
||||
!python {model: stock.location}: |
|
||||
ctx = {'product_id': ref('product_icecream')}
|
||||
refrigerator_location = self.pool.get('stock.location').browse(cr, uid, ref('location_refrigerator'), context=ctx)
|
||||
assert refrigerator_location.stock_real == 135.96, 'stock does not correspond in refrigerator location.'
|
||||
scrapped_location = self.browse(cr, uid, ref('stock_location_scrapped'), context=ctx)
|
||||
assert scrapped_location.stock_real == 0.010*4, 'scraped stock does not correspond in scrap location.'
|
||||
|
||||
-
|
||||
I check availabile stock after consumed and scraped.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
assert product.qty_available == 135.96, "Stock does not correspond."
|
||||
assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond."
|
||||
-
|
||||
I trace all incoming lots.
|
||||
-
|
||||
!python {model: stock.production.lot }: |
|
||||
lot = self.pool.get('stock.move.split').browse(cr, uid, ref('split_lot_incomming'), context=context)
|
||||
lot_ids = self.search(cr, uid, [('name', 'in', [x.name for x in lot.line_ids])])
|
||||
self.action_traceability(cr, uid, lot_ids, context=context)
|
||||
-
|
||||
I check outgoing shipment after stock availablity in refrigerator.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context)
|
||||
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
|
||||
#TOFIX: shipment should be assigned if stock available
|
||||
#assert shipment.state == "assigned", "Shipment should be assigned."
|
||||
#for move_line in shipment.move_lines:
|
||||
# assert move_line.state == "assigned", "Move should be assigned."
|
||||
self.force_assign(cr, uid, [shipment.id])
|
||||
-
|
||||
I deliver 5kgm Ice-cream to customer so I make partial deliver
|
||||
-
|
||||
!python {model: stock.partial.move}: |
|
||||
context.update({'active_model': 'stock.move', 'active_id': ref('outgoing_shipment_icecream'), 'active_ids': [ref('outgoing_shipment_icecream')]})
|
||||
-
|
||||
!record {model: stock.partial.move, id: partial_outgoing_icecream}:
|
||||
move_ids:
|
||||
- quantity: 5
|
||||
product_id: product_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
move_id: outgoing_shipment_icecream
|
||||
location_id: location_refrigerator
|
||||
location_dest_id: location_delivery_counter
|
||||
-
|
||||
!python {model: stock.partial.move }: |
|
||||
self.do_partial(cr, uid, [ref('partial_outgoing_icecream')], context=context)
|
||||
|
||||
-
|
||||
I packing outgoing shipment into box per 10kgm with unique tracking lot.
|
||||
-
|
||||
!python {model: stock.move}: |
|
||||
stock_split = self.pool.get('stock.split.into')
|
||||
move = self.browse(cr, uid, ref('outgoing_shipment_icecream'), context=context)
|
||||
context.update({'active_model': 'stock.move', 'active_id': move.id, 'active_ids': [move.id]})
|
||||
total_qty = move.product_qty
|
||||
split_qty = 10
|
||||
while(total_qty>0):
|
||||
split_id = stock_split.create(cr, uid, {'quantity': split_qty}, context=context)
|
||||
stock_split.split(cr, uid, [split_id], context=context)
|
||||
total_qty -= split_qty
|
||||
-
|
||||
I deliver outgoing shipment.
|
||||
-
|
||||
!python {model: stock.partial.picking}: |
|
||||
context.update({'active_model': 'stock.picking', 'active_id': ref('outgoing_shipment'), 'active_ids': [ref('outgoing_shipment')]})
|
||||
-
|
||||
!record {model: stock.partial.picking, id: partial_outgoing}:
|
||||
picking_id: outgoing_shipment
|
||||
-
|
||||
!python {model: stock.partial.picking }: |
|
||||
self.do_partial(cr, uid, [ref('partial_outgoing')], context=context)
|
||||
|
||||
-
|
||||
I check outgoing shipment after deliver.
|
||||
-
|
||||
!python {model: stock.picking}: |
|
||||
shipment = self.browse(cr, uid, ref("outgoing_shipment"), context=context)
|
||||
assert shipment.state == "done", "Shipment should be closed."
|
||||
for move_line in shipment.move_lines:
|
||||
assert move_line.state == "done", "Move should be closed."
|
||||
-
|
||||
I check availaible stock after deliver.
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
product = self.browse(cr, uid, ref('product_icecream'), context=context)
|
||||
assert round(product.qty_available, 2) == 5.96, "Stock does not correspond."
|
||||
assert round(product.virtual_available, 2) == -4.04, "Vitual stock does not correspond."
|
||||
Reference in New Issue
Block a user