[fix] tests

This commit is contained in:
Lorenzo Battistini
2013-05-11 09:36:49 +02:00
parent a79e486579
commit 3fda970e4c
2 changed files with 21 additions and 33 deletions

View File

@@ -49,9 +49,14 @@ class stock_production_lot(orm.Model):
uom.id, res[lot.id], context['uom'])
# Convert from price_type currency to asked one
if 'currency_id' in context:
res[lot.id] = self.pool.get('res.currency').compute(cr, uid,
lot.company_id.currency_id.id,
context['currency_id'], res[lot.id],context=context)
currency_id = (lot.company_id and lot.company_id.currency_id
and lot.company_id.currency_id.id) or (lot.product_id.company_id
and lot.product_id.company_id.currency_id
and lot.product_id.company_id.currency_id.id) or False
if currency_id:
res[lot.id] = self.pool.get('res.currency').compute(cr, uid,
currency_id,
context['currency_id'], res[lot.id],context=context)
return res
def do_change_standard_price(self, cr, uid, ids, datas, context=None):
@@ -175,12 +180,16 @@ class stock_move(orm.Model):
cr, uid, move, context=context)
if not move.product_id.cost_method == 'average' or not move.price_unit:
if move.product_id.lot_valuation and move.prodlot_id:
product_uom_obj = self.pool.get('product.uom')
qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id,
move.product_qty, move.product_id.uom_id.id)
if context is None:
context = {}
currency_ctx = dict(context, currency_id = move.company_id.currency_id.id)
amount_unit = move.prodlot_id.price_get(context=currency_ctx)[move.prodlot_id.id]
reference_amount = amount_unit * qty
res[0] = reference_amount
new_res = (reference_amount, res[1])
res = new_res
return res
def do_partial(self, cr, uid, ids, partial_datas, context=None):

View File

@@ -49,6 +49,7 @@
name: Lot0 for Ice cream
product_id: product_icecream
cost_method: average
standard_price: 70.0
-
!record {model: stock.production.lot, id: lot_icecream_1}:
name: Lot1 for Ice cream
@@ -139,41 +140,19 @@
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."
assert product.virtual_available == 90, "Vitual stock is not updated."
-
I complete physical inventory of Ice-cream.
-
!python {model: stock.inventory}: |
self.action_done(cr, uid, [ref('stock_inventory_icecream')], context=context)
-
I update the price of the Ice-cream lot.
-