[IMP] tests YAML stock

bzr revid: fp@tinyerp.com-20130630201323-b331o6nmrjjlpdh1
This commit is contained in:
Fabien Pinckaers 2013-06-30 22:13:23 +02:00
parent e58748609a
commit e61887ffae
9 changed files with 241 additions and 268 deletions

View File

@ -91,9 +91,9 @@ Dashboard / Reports for Warehouse Management will include:
'res_config_view.xml',
],
'test': [
# 'test/opening_stock.yml',
'test/inventory.yml',
'test/move.yml',
# 'test/shipment.yml',
# 'test/stock_report.yml',
],
'installable': True,
'application': True,

View File

@ -2,47 +2,15 @@
<openerp>
<data>
<record id="view_stock_graph_board" model="ir.ui.view">
<field name="name">report.stock.move.graph</field>
<field name="model">report.stock.move</field>
<field name="arch" type="xml">
<graph string="Moves Analysis" type="bar">
<field name="day"/>
<field name="product_qty" operator="+"/>
<field name="categ_id" group="True"/>
</graph>
</field>
</record>
<record model="ir.actions.act_window" id="action_stock_incoming_product_delay">
<field name="name">Incoming Products</field>
<field name="res_model">report.stock.move</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('type','=','in'),('day','&lt;=', time.strftime('%Y-%m-%d')),('day','&gt;',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="view_stock_graph_board"></field>
<field name="context">{'search_default_in':1}</field>
</record>
<record model="ir.actions.act_window" id="action_stock_outgoing_product_delay">
<field name="name">Outgoing Products</field>
<field name="res_model">report.stock.move</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="domain">[('type','=','out'),('day','&lt;=', time.strftime('%Y-%m-%d')),('day','&gt;',(context_today()-datetime.timedelta(days=15)).strftime('%Y-%m-%d'))]</field>
<field name="view_id" ref="view_stock_graph_board"></field>
<field name="context">{'search_default_out':1}</field>
</record>
<record id="board_warehouse_form" model="ir.ui.view">
<field name="name">board.warehouse.form</field>
<field name="model">board.board</field>
<field name="arch" type="xml">
<form string="Warehouse board" version="7.0">
<board style="1-1">
<column>
<action name="%(action_stock_incoming_product_delay)d" string="Incoming Products"/>
<column name="left">
</column>
<column>
<action name="%(action_stock_outgoing_product_delay)d" string="Outgoing Products"/>
<column name="right">
</column>
</board>
</form>

View File

@ -231,10 +231,11 @@ class product_product(osv.osv):
operator = context.get('compute_child',True) and 'child_of' or 'in'
domain = context.get('force_company', False) and ['&', ('company_id', '=', context['force_company'])] or []
domain += [('product_id', 'in', ids)]
return (
domain + [('location_id', operator, location_ids)],
domain + ['&', ('location_src_id', operator, location_ids), '!', ('location_dest_id', operator, location_ids)],
domain + ['&', ('location_dest_id', operator, location_ids), '!', ('location_src_id', operator, location_ids)]
domain + ['&', ('location_dest_id', operator, location_ids), '!', ('location_id', operator, location_ids)],
domain + ['&', ('location_id', operator, location_ids), '!', ('location_dest_id', operator, location_ids)]
)
def _get_domain_dates(self, cr, uid, ids, context):
@ -251,9 +252,9 @@ class product_product(osv.osv):
context = context or {}
field_names = field_names or []
domain_quant, domain_move_in, domain_move_out = self._get_domain_locations(cr, uid, ids, key='location_id', context=context)
domain_move_in += self._get_domain_dates(cr, uid, ids, context=context)
domain_move_out += self._get_domain_dates(cr, uid, ids, context=context)
domain_quant, domain_move_in, domain_move_out = self._get_domain_locations(cr, uid, ids, context=context)
domain_move_in += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))]
domain_move_out += self._get_domain_dates(cr, uid, ids, context=context) + [('state','not in',('done','cancel'))]
if context.get('lot_id', False):
domain_quants.append(('lot_id','=',context['lot_id']))
@ -265,9 +266,9 @@ class product_product(osv.osv):
quants = self.pool.get('stock.quant').read_group(cr, uid, domain_quant, ['product_id', 'qty'], ['product_id'], context=context)
quants = dict(map(lambda x: (x['product_id'], x['qty']), quants))
moves_in = dict(map(lambda x: (x['product_id'], x['product_qty']), moves_in))
moves_out = dict(map(lambda x: (x['product_id'], x['product_qty']), moves_out))
quants = dict(map(lambda x: (x['product_id'][0], x['qty']), quants))
moves_in = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_in))
moves_out = dict(map(lambda x: (x['product_id'][0], x['product_qty']), moves_out))
res = {}
for id in ids:

View File

@ -176,7 +176,6 @@ class stock_quant(osv.osv):
# Used for negative quants to reconcile after compensated by a new positive one
'propagated_from_id': fields.many2one('stock.quant', 'Linked Quant', help = 'The negative quant this is coming from'),
'propagated_to_ids': fields.one2many('stock.quant', 'propagated_from_id', 'Linked Quants', help = 'The negative quant this is coming from'),
}
def quants_reserve(self, cr, uid, quants, move, context=None):
@ -208,7 +207,8 @@ class stock_quant(osv.osv):
self._account_entry_move(cr, uid, quant, location_from, location_to, move, context=context)
# FP Note: TODO: implement domain preference that tries to retrieve first with this domain
def quants_get(self, cr, uid, location, product, qty, domain=[('qty','>',0.0)], domain_preference=[], context=None):
# This will be used for putaway strategies
def quants_get(self, cr, uid, location, product, qty, domain=None, domain_preference=[], context=None):
"""
Use the removal strategies of product to search for the correct quants
@ -217,6 +217,7 @@ class stock_quant(osv.osv):
:qty in UoM of product
:lot_id NOT USED YET !
"""
domain = domain or [('qty','>',0.0)]
removal_strategy = self.pool.get('stock.location').get_removal_strategy(cr, uid, location, product, context=context) or 'fifo'
if removal_strategy=='fifo':
result = self._quants_get_fifo(cr, uid, location, product, qty, domain, context=context)
@ -245,6 +246,7 @@ class stock_quant(osv.osv):
if move.location_id.usage == 'internal':
vals['location_id'] = move.location_id.id
vals['qty'] = -qty
vals['cost'] = 0.0
new_quant_id = self.create(cr, uid, vals, context=context)
self.write(cr, uid, [quant_id], {'propagated_from_id': new_quant_id}, context=context)
obj = self.browse(cr, uid, quant_id, context=context)
@ -256,7 +258,7 @@ class stock_quant(osv.osv):
self._price_update(cr, uid, obj, price_unit, context=context)
return obj
def _quand_split(self, cr, uid, quant, qty, context=None):
def _quant_split(self, cr, uid, quant, qty, context=None):
context=context or {}
if quant.qty<=qty:
return False
@ -265,31 +267,37 @@ class stock_quant(osv.osv):
quant.refresh()
return new_quant
"""
When new quant arrive in a location, try to reconcile it with
negative quants. If it's possible, apply the cost of the new
quant to the conter-part of the negative quant.
"""
def _quant_reconcile_negative(self, cr, uid, quant, context=None):
'''
This function will reconcile the negative quants with the amount provided and give them this price
:param ids : Negative quants to reconcile with
:param move
:param qty: in product uom as incoming quantity or as quantity from the quant to be reconciled
:param price: in product uom as price to be put on propagated quants
:param history_moves_to_transfer: when moving, we need to pass the history_ids of the quant that will be cancelled with the negative quant (list of browse records)
:return: amount that stays open + propagated quants from the reconciled quants which get a price, ... now
'''
if quant.location_id <> 'internal': return False
quants = self.quants_get(cr, uid, quant.location_id, quant.product_id.id, quant.qty, [('qty','<','0')], context=context)
for quant, qty in quants:
if not quant: continue
if quant.location_id.usage <> 'internal': return False
quants = self.quants_get(cr, uid, quant.location_id, quant.product_id, quant.qty, [('qty','<','0')], context=context)
result = False
for quant_neg, qty in quants:
if not quant_neg: continue
result=True
# FP Note: to implement
#self.split(...)
#self.write(cr, uid, quant.id, {
# 'propagated_from_id': False,
# 'history_ids': [(4, x.id) for x in history_moves_to_transfer]}, context=context)
#self.unlink(cr, uid, [quant.id], context=context)
#self._price_update(cr, uid, quant.id, quant.price)
# ''cost': price,
self._quant_split(cr, uid, quant_neg, qty, context=context)
self._quant_split(cr, uid, quant, qty, context=context)
return res
cost = quant.id
self.write(cr, uid, [quant.id, quant_neg.id], {
'cost': 0.0,
}, context=context)
quants2 = self.quants_get(cr, uid, False, quant.product_id, quant_neg.qty, [('propagated_from_id','=',quant_neg.id)], context=context)
for qu2, qt2 in quants2:
if not qu2: raise 'Error: negative stock linked to nothing'
self._quant_split(cr, uid, qu2, qt2, context=context)
self.write(cr, uid, [qu2.id], {
'propagated_from_id': False
}, context=context)
self._price_update(cr, uid, qu2, cost, context=context)
return result
# FP Note: this is where we should post accounting entries for adjustment
def _price_update(self, cr, uid, quant, newprice, context=None):
@ -299,8 +307,8 @@ class stock_quant(osv.osv):
# Implementation of removal strategies
#
def _quants_get_order(self, cr, uid, location, product, quantity, domain=[], orderby='in_date', context=None):
domain = [('location_id', 'child_of', location.id), ('product_id','=',product.id),
('reservation_id', '=', False)] + domain
domain += location and [('location_id', 'child_of', location.id)] or []
domain += [('product_id','=',product.id), ('reservation_id', '=', False)] + domain
res = []
offset = 0
while quantity > 0:
@ -315,6 +323,7 @@ class stock_quant(osv.osv):
else:
res += [(quant, quantity)]
quantity = 0
break
offset += 10
return res
@ -1578,7 +1587,7 @@ class stock_move(osv.osv):
uom_obj = self.pool.get('product.uom')
res = {}
for m in self.browse(cr, uid, ids, context=context):
res[m.id] = uom_obj._compute_qty_obj(cr, uid, m.product_uom, product_qty, m.product_id.uom_id)
res[m.id] = uom_obj._compute_qty_obj(cr, uid, m.product_uom, m.product_uom_qty, m.product_id.uom_id)
return res
_columns = {
@ -1846,8 +1855,8 @@ class stock_move(osv.osv):
@return: Dictionary of values
"""
result = {
'product_qty': 0.00
}
'product_uom_qty': 0.00
}
warning = {}
if (not product_id) or (product_uos_qty <=0.0):
@ -1868,9 +1877,9 @@ class stock_move(osv.osv):
break
if product_uos and product_uom and (product_uom != product_uos):
result['product_qty'] = product_uos_qty / uos_coeff['uos_coeff']
result['product_uom_qty'] = product_uos_qty / uos_coeff['uos_coeff']
else:
result['product_qty'] = product_uos_qty
result['product_uom_qty'] = product_uos_qty
return {'value': result, 'warning': warning}
def onchange_product_id(self, cr, uid, ids, prod_id=False, loc_id=False,
@ -1896,7 +1905,7 @@ class stock_move(osv.osv):
result = {
'product_uom': product.uom_id.id,
'product_uos': uos_id,
'product_qty': 1.00,
'product_uom_qty': 1.00,
'product_uos_qty' : self.pool.get('stock.move').onchange_quantity(cr, uid, ids, prod_id, 1.00, product.uom_id.id, uos_id)['value']['product_uos_qty'],
}
if not ids:
@ -2052,7 +2061,7 @@ class stock_move(osv.osv):
if todo:
self.action_confirm(cr, uid, todo, context=context)
qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id)
qty = move.product_qty
quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, context=context)
quant_obj.quants_move(cr, uid, quants, move, context=context)
@ -2423,10 +2432,13 @@ class stock_inventory(osv.osv):
move_ids = []
for line in inv.inventory_line_id:
pid = line.product_id.id
product_context.update(uom=line.product_uom.id, to_date=inv.date, date=inv.date, lot_id=line.prod_lot_id.id)
# FP Note: TODO check if it does not take recursive values
# FP Note: TODO implement lot matching
amount = line.product_id.qty_available
product_context.update(
location=line.location_id.id,
lot_id=line.prod_lot_id and line.prod_lot_id.id or False
)
qty = self.pool.get('product.product').browse(cr, uid, line.product_id.id, context=product_context).qty_available
amount = self.pool.get('product.uom')._compute_qty_obj(cr, uid, line.product_id.uom_id, qty, line.product_uom, context=context)
change = line.product_qty - amount
lot_id = line.prod_lot_id.id
if change:
@ -2441,13 +2453,13 @@ class stock_inventory(osv.osv):
if change > 0:
value.update( {
'product_qty': change,
'product_uom_qty': change,
'location_id': location_id,
'location_dest_id': line.location_id.id,
})
else:
value.update( {
'product_qty': -change,
'product_uom_qty': -change,
'location_id': line.location_id.id,
'location_dest_id': location_id,
})

View File

@ -42,7 +42,7 @@
<field name="arch" type="xml">
<tree string="Stock Inventory Lines">
<field name="product_id"/>
<field name="product_uom_qty"/>
<field name="product_qty"/>
<field name="product_uom" groups="product.group_uom"/>
<field name="location_id" groups="stock.group_locations"/>
</tree>
@ -55,7 +55,7 @@
<form string="Stock Inventory Lines" version="7.0">
<group col="4">
<field context="{'location':location_id, 'uom':product_uom, 'to_date':parent.date}" name="product_id" on_change="on_change_product_id(location_id,product_id,product_uom,parent.date)" domain="[('type','&lt;&gt;','service')]"/>
<field name="product_uom_qty"/>
<field name="product_qty"/>
<field name="product_uom" groups="product.group_uom"/>
<field domain="[('usage','=','internal')]" name="location_id"/>
<button name="%(stock.action_view_stock_inventory_line_split)d"

View File

@ -0,0 +1,83 @@
-
I create an inventory of 10 products
-
!record {model: stock.inventory, id: inventory_test0}:
name: Test
inventory_line_id:
- product_id: product.product_product_3
product_qty: 10
location_id: stock.stock_location_14
-
I post this inventory
-
!python {model: stock.inventory}: |
self.action_confirm(cr, uid, [ref('inventory_test0')], context=context)
self.action_done(cr, uid, [ref('inventory_test0')], context=context)
-
I check that this inventory has a stock.move and a quant
-
!python {model: stock.inventory}: |
inv = self.browse(cr, uid, ref('inventory_test0'), context=context)
assert len(inv.move_ids) == 1, "No move created for the inventory."
assert len(inv.move_ids[0].quant_ids) >= 1, "No quant created for this inventory"
-
I check that the quantity on hand is 10 on the location and it's parent.
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_14!' % (product.qty_available,)
context['location'] = ref('stock.stock_location_stock')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==10, 'Expecting 10 products, got %.2f on location stock_location_stock!' % (product.qty_available,)
-
I check that the quantity on hand is 0 on a brother location
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_components')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==0, 'Expecting 0 products, got %.2f on location stock_location_components!' % (product.qty_available,)
-
I create an inventory of 20 products
-
!record {model: stock.inventory, id: inventory_test1}:
name: Test
inventory_line_id:
- product_id: product.product_product_3
product_qty: 20
location_id: stock.stock_location_14
-
I post this new inventory
-
!python {model: stock.inventory}: |
self.action_confirm(cr, uid, [ref('inventory_test1')], context=context)
self.action_done(cr, uid, [ref('inventory_test1')], context=context)
-
I check that the quantity on hand is 20 on the location and it's parent.
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==20, 'Expecting 20 products, got %.2f on location stock_location_14!' % (product.qty_available,)
-
!record {model: stock.inventory, id: inventory_test2}:
name: Test
inventory_line_id:
- product_id: product.product_product_3
product_qty: 18
location_id: stock.stock_location_14
-
I post this new inventory
-
!python {model: stock.inventory}: |
self.action_confirm(cr, uid, [ref('inventory_test2')], context=context)
self.action_done(cr, uid, [ref('inventory_test2')], context=context)
-
I check that the quantity on hand is 18 on the location and it's parent.
-
!python {model: product.product}: |
context['location'] = ref('stock.stock_location_14')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==18, 'Expecting 18 products, got %.2f on location stock_location_14!' % (product.qty_available,)

View File

@ -0,0 +1,91 @@
-
I create a move of 5 products from stock to customer
-
!record {model: stock.move, id: move_test0}:
name: Move Products
product_id: product.product_product_3
product_uom_qty: 5
product_uom: product.product_uom_unit
product_uos_qty: 5
product_uos: product.product_uom_unit
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
-
I confirm the move to be processed in the future
-
!python {model: stock.move}: |
self.action_confirm(cr, uid, [ref('move_test0')], context=context)
-
I check that the quantity on hand is 18 and virutal is 13
-
!python {model: product.product}: |
context['location'] = False
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==18, 'Expecting 18 products in stock, got %.2f!' % (product.qty_available,)
assert product.virtual_available==13.0, 'Expecting 13 products in virtual stock, got %.2f!' % (product.virtual_available,)
-
I validate the move
-
!python {model: stock.move}: |
self.action_done(cr, uid, [ref('move_test0')], context=context)
-
I check that the quantity on hand is 13 and 5 products are at customer location
-
!python {model: product.product}: |
context['location'] = False
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==13, 'Expecting 13 products in stock, got %.2f!' % (product.qty_available,)
context['location'] = ref('stock.stock_location_customers')
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available==5, 'Expecting 5 products in customer location, got %.2f!' % (product.qty_available,)
-
In order to test negative quants, I will deliver 14 products to the customer
-
!record {model: stock.move, id: move_test1}:
name: Move 14 Products
product_id: product.product_product_3
product_uom_qty: 14
product_uom: product.product_uom_unit
product_uos_qty: 14
product_uos: product.product_uom_unit
location_id: stock.stock_location_stock
location_dest_id: stock.stock_location_customers
-
I confirm and validate the move
-
!python {model: stock.move}: |
self.action_confirm(cr, uid, [ref('move_test1')], context=context)
self.action_done(cr, uid, [ref('move_test1')], context=context)
-
I check that the quantity on hand is -2
-
!python {model: product.product}: |
context['location'] = False
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available == -1, 'Expecting -1 products in stock, got %.2f!' % (product.qty_available,)
-
To compensate negative quants, I will receive 5 products from the supplier
-
!record {model: stock.move, id: move_test2}:
name: Move 15 Products
product_id: product.product_product_3
product_uom_qty: 5
product_uom: product.product_uom_unit
product_uos_qty: 5
product_uos: product.product_uom_unit
location_id: stock.stock_location_suppliers
location_dest_id: stock.stock_location_stock
-
I confirm and validate the move
-
!python {model: stock.move}: |
self.action_confirm(cr, uid, [ref('move_test2')], context=context)
self.action_done(cr, uid, [ref('move_test2')], context=context)
-
I check that the quantity on hand is 4
-
!python {model: product.product}: |
context['location'] = False
product = self.browse(cr, uid, ref('product.product_product_3'), context=context)
assert product.qty_available == 4, 'Expecting 4 products in stock, got %.2f!' % (product.qty_available,)

View File

@ -1,131 +0,0 @@
-
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 update the current stock of the Ice-cream with 10 kgm in Small Refrigerator in lot0.
-
!record {model: stock.change.product.qty, id: change_qty}:
location_id: location_refrigerator_small
new_quantity: 10
product_id: product_icecream
lot_id: lot_icecream_1
-
!python {model: stock.change.product.qty}: |
self.change_product_qty(cr, uid, [ref('change_qty')], context=context)
-
I check available stock of Ice-cream after update stock.
-
!python {model: product.product}: |
product = self.browse(cr, uid, ref('product_icecream'), context=context)
assert product.qty_available == 10, "Stock is not updated."
-
I merge inventory.
-
!python {model: stock.inventory.merge }: |
context.update({'active_model': 'stock.inventory', 'active_id': ref('stock_inventory_icecream'), 'active_ids': [ref('stock_inventory_icecream')]})
-
!record {model: stock.inventory.merge, id: merge_inventory}:
-
!python {model: stock.inventory.merge }: |
self.do_merge(cr, uid, [ref('merge_inventory')], context=context)
-
I cancel inventory.
-
!python {model: stock.inventory}: |
self.action_cancel_inventory(cr, uid, [ref('stock_inventory_icecream')])
-
I reset to draft inventory.
-
!python {model: stock.inventory}: |
self.action_cancel_draft(cr, uid, [ref('stock_inventory_icecream')])
-
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.lot_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
lot_id: lot_icecream_0
- quantity: 4
lot_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 close physical inventory of Ice-cream.
-
!python {model: stock.inventory}: |
self.action_done(cr, uid, [ref('stock_inventory_icecream')], context=context)
-
I check closed move and real stock of Ice-cream after closed physical inventory.
-
!python {model: stock.inventory}: |
inventory = self.browse(cr, uid, ref('stock_inventory_icecream'), context=context)
assert inventory.state == 'done', "inventory is not closed."
for move_line in inventory.move_ids:
assert move_line.state == 'done', "Move is not closed."
product = self.pool.get('product.product').browse(cr, uid, ref('product_icecream'), context=context)
product.qty_available == 100, "Real stock is not updated."
-
I check stock in lot.
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('lot_icecream_0'), context=context)
assert lot.stock_available == 50, "Stock in lot is not correspond."

View File

@ -1,51 +0,0 @@
-
I print a stock overview report of location.
-
!python {model: stock.location}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('location_refrigerator')], 'lot.stock.overview', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overview'+format), 'wb+').write(data)
-
I print a Stock Overview report of location with child location.
-
!python {model: stock.location}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('location_refrigerator')], 'lot.stock.overview_all', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-overviewall'+format), 'wb+').write(data)
-
I print a Stock Inventory report.
-
!python {model: stock.inventory}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('stock_inventory_icecream')], 'stock.inventory.move', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-stock_inventory_move.'+format), 'wb+').write(data)
-
I print a outgoing shipment report.
-
!python {model: stock.picking}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('outgoing_shipment')], 'stock.picking.list', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-picking_list'+format), 'wb+').write(data)
-
I print stock Report.
-
!python {model: product.product}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('product_icecream')], 'stock.product.history', {}, {})
if tools.config['test_report_directory']:
file(os.path.join(tools.config['test_report_directory'], 'stock-product_stock_report.'+format), 'wb+').write(data)