[IMP] Change stock move price to company currency and remove rounding

bzr revid: jco@openerp.com-20130506103939-bioi6i6inyuz2kq6
This commit is contained in:
Josse Colpaert 2013-05-06 12:39:39 +02:00
parent cc3c8f2864
commit 5b69ce1902
3 changed files with 12 additions and 6 deletions

View File

@ -5,6 +5,7 @@
<field name="supply_method">buy</field>
<field name="list_price">7.0</field>
<field name="standard_price">5.0</field>
<field name="cost_method">standard</field>
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
<field name="uos_id" ref="product.product_uom_kgm" />
@ -34,7 +35,7 @@
<record id="product_product_from" model="product.product">
<field name="supply_method">buy</field>
<field name="list_price">8.0</field>
<field name="standard_price">6.0</field>
<!-- <field name="standard_price">6.0</field>-->
<field name="uom_id" ref="product.product_uom_unit"/>
<field name="uom_po_id" ref="product.product_uom_unit"/>
<field name="uos_id" ref="product.product_uom_kgm" />

View File

@ -1611,7 +1611,7 @@ class stock_move(osv.osv):
"* Waiting Availability: This state is reached when the procurement resolution is not straight forward. It may need the scheduler to run, a component to me manufactured...\n"\
"* Available: When products are reserved, it is set to \'Available\'.\n"\
"* Done: When the shipment is processed, the state is \'Done\'."),
'price_unit': fields.float('Unit Price', digits_compute= dp.get_precision('Account'), help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
'price_unit': fields.float('Unit Price', help="Technical field used to record the product cost set by the user during a picking confirmation (when average price costing method is used)"),
'price_currency_id': fields.many2one('res.currency', 'Currency for average price', help="Technical field used to record the currency chosen by the user during a picking confirmation (when average price costing method is used)"),
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
'backorder_id': fields.related('picking_id','backorder_id',type='many2one', relation="stock.picking", string="Back Order of", select=True),

View File

@ -145,7 +145,7 @@ class stock_move(osv.osv):
if move.picking_id.type == 'out' and cost_method in ['fifo', 'lifo']:
#get_stock_matchings will convert to currency and UoM of this stock move
tuples = product_obj.get_stock_matchings_fifolifo(cr, uid, [product.id], product_qty, cost_method == 'fifo',
product_uom, move.price_currency_id.id, context=context)
product_uom, move.company_id.currency_id.id, context=context) #Always move of the company
price_amount = 0.0
amount = 0.0
move_currency_id = move.company_id.currency_id.id
@ -157,7 +157,6 @@ class stock_move(osv.osv):
move_in = self.browse(cr, uid, match[0], context=context)
#Reduce remaining quantity
self.write(cr, uid, match[0], { 'qty_remaining': move_in.qty_remaining - match[3]}, context=context)
price_amount += match[1] * match[2]
amount += match[1]
self.write(cr, uid, move.id, {'price_unit': price_amount / amount}, context=context)
@ -180,9 +179,15 @@ class stock_move(osv.osv):
# When the move is products returned to supplier or return products from customer
# then the price should be the price from the original move
elif cost_method in ['fifo', 'lifo']:
#The currency in the stock move should be the currency of the company
if product_currency != move.company_id.currency_id.id:
new_price = currency_obj.compute(cr, uid, product_currency, move.company_id.currency_id.id,
product_price, round=False)
else:
new_price = product_price
self.write(cr, uid, [move.id],
{'price_unit': product_price,
'price_currency_id': product_currency})
{'price_unit': new_price,
'price_currency_id': move.company_id.currency_id.id})
return True
class stock_move_matching(osv.osv):