[IMP] Putaway + change fifo / lifo costing method into real costing method
bzr revid: jco@openerp.com-20130625152620-kz0rxl6622nie8om
This commit is contained in:
parent
11b680869f
commit
0ad0bcb3ef
|
@ -314,7 +314,7 @@ class product_template(osv.osv):
|
|||
'volume': fields.float('Volume', help="The volume in m3."),
|
||||
'weight': fields.float('Gross Weight', digits_compute=dp.get_precision('Stock Weight'), help="The gross weight in Kg."),
|
||||
'weight_net': fields.float('Net Weight', digits_compute=dp.get_precision('Stock Weight'), help="The net weight in Kg."),
|
||||
'cost_method': fields.property(type='selection', selection = [('standard','Standard Price'), ('average','Average Price'), ('fifo', 'FIFO price'), ('lifo', 'LIFO price')],
|
||||
'cost_method': fields.property(type='selection', selection = [('standard','Standard Price'), ('average','Average Price'), ('real', 'Real Price')],
|
||||
help="""Standard Price: The cost price is manually updated at the end of a specific period (usually every year)
|
||||
Average Price: The cost price is recomputed at each incoming shipment
|
||||
FIFO Price: The cost price is recomputed at each outgoing shipment FIFO
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
-
|
||||
!python {model: product.product}: |
|
||||
assert self.browse(cr, uid, ref("product_variable_icecream")).standard_price == 75.0, 'After second reception, we should have an average price of 75.0 on the product'
|
||||
self.write(cr, uid, [ref("product_variable_icecream")], {'cost_method': 'fifo'}, context=context)
|
||||
self.write(cr, uid, [ref("product_variable_icecream")], {'cost_method': 'real'}, context=context)
|
||||
-
|
||||
Create picking to send some goods
|
||||
-
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
procure_method: make_to_stock
|
||||
cost_method: fifo
|
||||
cost_method: real
|
||||
valuation: real_time
|
||||
property_stock_account_input: account.o_expense
|
||||
property_stock_account_output: account.o_income
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
uom_id: product.product_uom_kgm
|
||||
uom_po_id: product.product_uom_kgm
|
||||
procure_method: make_to_stock
|
||||
cost_method: fifo
|
||||
cost_method: real
|
||||
valuation: real_time
|
||||
property_stock_account_input: account.o_expense
|
||||
property_stock_account_output: account.o_income
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
uom_po_id: product.product_uom_kgm
|
||||
procure_method: make_to_stock
|
||||
valuation: real_time
|
||||
cost_method: lifo
|
||||
cost_method: real
|
||||
property_stock_account_input: account.o_expense
|
||||
property_stock_account_output: account.o_income
|
||||
description: LIFO 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.
|
||||
|
|
|
@ -183,7 +183,7 @@ class report_stock_inventory(osv.osv):
|
|||
ctx = context.copy()
|
||||
ctx['force_company'] = line.company_id.id
|
||||
prod = product_obj.browse(cr, uid, line.product_id.id, context=ctx)
|
||||
if prodbrow[(line.company_id.id, line.product_id.id)].cost_method in ('fifo', 'lifo'):
|
||||
if prodbrow[(line.company_id.id, line.product_id.id)].cost_method in ('real'):
|
||||
res[line.id] = line.value
|
||||
else:
|
||||
res[line.id] = prodbrow[(line.company_id.id, line.product_id.id)].standard_price * line.product_qty
|
||||
|
|
|
@ -2394,18 +2394,24 @@ class stock_move(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.product_id.type == 'consu' or move.location_id.usage == 'supplier':
|
||||
if move.product_id.type == 'consu': #or move.location_id.usage == 'supplier':
|
||||
if move.state in ('confirmed', 'waiting'):
|
||||
done.append(move.id)
|
||||
pickings[move.picking_id.id] = 1
|
||||
continue
|
||||
print "move state:", move.state
|
||||
if move.state in ('confirmed', 'waiting'):
|
||||
|
||||
# Split for putaway first
|
||||
self.splitforputaway(cr, uid, [move.id], context=context)
|
||||
|
||||
# Important: we must pass lock=True to _product_reserve() to avoid race conditions and double reservations
|
||||
# res = self.pool.get('stock.location')._product_reserve(cr, uid, [move.location_id.id], move.product_id.id, move.product_qty, {'uom': move.product_uom.id}, lock=True)
|
||||
|
||||
#Convert UoM qty -> check rounding now in product_reserver
|
||||
|
||||
|
||||
|
||||
#Split for source locations
|
||||
qty = uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, move.product_id.uom_id.id)
|
||||
res2 = quant_obj.choose_quants(cr, uid, move.location_id.id, move.product_id.id, qty, context=context)
|
||||
|
@ -2443,7 +2449,7 @@ class stock_move(osv.osv):
|
|||
move_id = self.copy(cr, uid, move.id, {'product_uos_qty': product_uos_qty, 'product_qty': r[0], 'location_id': r[1]})
|
||||
done.append(move_id)
|
||||
|
||||
self.splitforputaway(cr, uid, [move.id], context=context)
|
||||
|
||||
|
||||
|
||||
if done:
|
||||
|
@ -2799,10 +2805,10 @@ class stock_move(osv.osv):
|
|||
# Consists of access rights
|
||||
# TODO Check if amount_currency is not needed
|
||||
match_obj = self.pool.get("stock.move.matching")
|
||||
if type == 'out' and move.product_id.cost_method in ['fifo', 'lifo']:
|
||||
if type == 'out' and move.product_id.cost_method in ['real']:
|
||||
for match in match_obj.browse(cr, uid, matches, context=context):
|
||||
move_list += [(match.qty, match.qty * match.price_unit_out)]
|
||||
elif type == 'in' and move.product_id.cost_method in ['fifo', 'lifo']:
|
||||
elif type == 'in' and move.product_id.cost_method in ['real']:
|
||||
move_list = [(move.product_qty, reference_amount)]
|
||||
else:
|
||||
move_list = [(move.product_qty, reference_amount)]
|
||||
|
@ -3066,7 +3072,7 @@ class stock_move(osv.osv):
|
|||
#Search out moves from quants
|
||||
|
||||
quant_obj = self.pool.get("stock.quant")
|
||||
if cost_method in ['fifo', 'lifo']:
|
||||
if cost_method in ['real']:
|
||||
quants_dict = quant_obj.get_out_moves_from_quants(cr, uid, quants, context=context)
|
||||
for out_mov in self.browse(cr, uid, quants_dict.keys(), context=context):
|
||||
quants_from_move = quant_obj.search(cr, uid, [('history_ids', 'in', out_mov.id), ('propagated_from_id', '=', False)], context=context)
|
||||
|
@ -3141,7 +3147,7 @@ class stock_move(osv.osv):
|
|||
# price_amount += match[1] * match[2]
|
||||
# amount += match[1]
|
||||
#Write price on out move
|
||||
if product_avail[product.id] >= product_uom_qty and product.cost_method in ['fifo', 'lifo']:
|
||||
if product_avail[product.id] >= product_uom_qty and product.cost_method in ['real']:
|
||||
if amount > 0:
|
||||
self.write(cr, uid, move.id, {'price_unit': price_amount / move_qty}, context=context) #Should be converted
|
||||
product_obj.write(cr, uid, product.id, {'standard_price': price_amount / amount}, context=ctx)
|
||||
|
|
|
@ -165,7 +165,6 @@ class stock_move(osv.osv):
|
|||
'''
|
||||
putaway_obj = self.pool.get("product.putaway")
|
||||
location_obj = self.pool.get("stock.location")
|
||||
print "SPLIT FOR PUTAWAY"
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
putaways = putaway_obj.search(cr, uid, [('product_categ_id','=', move.product_id.categ_id.id), ('location_id', '=', move.location_dest_id.id)], context=context)
|
||||
print putaways
|
||||
|
|
Loading…
Reference in New Issue