[MERGE] From Joel GrandGuillaume (Camp2Camp)
bzr revid: stephane@openerp.com-20100325133524-bopyjvq6dr6xq0xr
This commit is contained in:
@@ -147,8 +147,9 @@ class account_analytic_line(osv.osv):
|
||||
|
||||
# Compute based on pricetype
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,company_obj.browse(cr,uid,company_id).property_valuation_price_type.id)
|
||||
# Take the company currency as the reference one
|
||||
context['currency_id']=company_obj.browse(cr,uid,company_id).currency_id.id
|
||||
amount_unit=prod.price_get(pricetype.field, context)[prod.id]
|
||||
|
||||
amount=amount_unit*unit_amount or 1.0
|
||||
return {'value': {
|
||||
'amount': - round(amount, 2),
|
||||
|
||||
@@ -220,6 +220,7 @@ class hr_expense_line(osv.osv):
|
||||
|
||||
# Compute based on pricetype of employee company
|
||||
pricetype_id = self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.property_valuation_price_type.id
|
||||
context['currency_id']=self.pool.get('hr.employee').browse(cr,uid,employee_id).user_id.company_id.currency_id.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,pricetype_id)
|
||||
amount_unit=product.price_get(pricetype.field, context)[product.id]
|
||||
|
||||
|
||||
@@ -36,16 +36,6 @@ class res_company(osv.osv):
|
||||
help="The price type field in the selected price type will be used, instead of the default one, \
|
||||
for valuation of product in the current company"),
|
||||
}
|
||||
|
||||
def _check_currency(self, cr, uid, ids):
|
||||
for rec in self.browse(cr, uid, ids):
|
||||
if rec.currency_id.id <> rec.property_valuation_price_type.currency_id.id:
|
||||
return False
|
||||
return True
|
||||
|
||||
_constraints = [
|
||||
(_check_currency, 'Error! You can not chooes a pricetype in a different currency than your company (Not supported now).', ['property_valuation_price_type'])
|
||||
]
|
||||
|
||||
res_company()
|
||||
|
||||
|
||||
@@ -523,7 +523,6 @@ class product_product(osv.osv):
|
||||
def price_get(self, cr, uid, ids, ptype='list_price', context={}):
|
||||
res = {}
|
||||
product_uom_obj = self.pool.get('product.uom')
|
||||
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
res[product.id] = product[ptype] or 0.0
|
||||
if ptype == 'list_price':
|
||||
@@ -533,6 +532,16 @@ class product_product(osv.osv):
|
||||
uom = product.uos_id or product.uom_id
|
||||
res[product.id] = product_uom_obj._compute_price(cr, uid,
|
||||
uom.id, res[product.id], context['uom'])
|
||||
# Convert from price_type currency to asked one
|
||||
if 'currency_id' in context:
|
||||
pricetype_obj = self.pool.get('product.price.type')
|
||||
# Take the price_type currency from the product field
|
||||
# This is right cause a field cannot be in more than one currency
|
||||
price_type_id = pricetype_obj.search(cr,ui,['field','=',ptype])[0]
|
||||
price_type_currency_id = pricetype_obj.browse(cr,uid,price_type_id).currency_id.id
|
||||
res[product.id] = self.pool.get('res.currency').compute(cr, uid, price_type_currency_id,
|
||||
context['currency_id'], res[product.id],context=context)
|
||||
|
||||
return res
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
||||
+12
-4
@@ -122,8 +122,13 @@ class stock_location(osv.osv):
|
||||
for r in result:
|
||||
c = (context or {}).copy()
|
||||
c['location'] = id
|
||||
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read, pricetype.field], context=c)
|
||||
final_value += (product[field_to_read] * product[pricetype.field])
|
||||
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read], context=c)
|
||||
# Compute the amount_unit in right currency
|
||||
|
||||
context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id
|
||||
amount_unit=self.pool.get('product.product').browse(cr,uid,r['product_id']).price_get(pricetype.field, context)[r['product_id']]
|
||||
|
||||
final_value += (product[field_to_read] * amount_unit)
|
||||
return final_value
|
||||
|
||||
def _product_value(self, cr, uid, ids, field_names, arg, context={}):
|
||||
@@ -223,6 +228,7 @@ class stock_location(osv.osv):
|
||||
# Take the user company and pricetype
|
||||
price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
context['currency_id']=self.pool.get('res.users').browse(cr,uid,uid).company_id.currency_id.id
|
||||
|
||||
if not product_ids:
|
||||
product_ids = product_obj.search(cr, uid, [])
|
||||
@@ -666,7 +672,9 @@ class stock_picking(osv.osv):
|
||||
if type in ('in_invoice', 'in_refund'):
|
||||
# Take the user company and pricetype
|
||||
price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
|
||||
context['currency_id']=move_line.company_id.currency_id.id
|
||||
|
||||
amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
|
||||
return amount_unit
|
||||
else:
|
||||
@@ -1385,7 +1393,7 @@ class stock_move(osv.osv):
|
||||
# Base computation on valuation price type
|
||||
else:
|
||||
company_id=move.company_id.id
|
||||
|
||||
context['currency_id']=move.company_id.currency_id.id
|
||||
pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id)
|
||||
amount_unit=move.product_id.price_get(pricetype.field, context)[move.product_id.id]
|
||||
amount=amount_unit * q or 1.0
|
||||
|
||||
@@ -126,7 +126,8 @@ def _do_split(self, cr, uid, data, context):
|
||||
|
||||
product = product_obj.browse(cr, uid, [move.product_id.id])[0]
|
||||
user = users_obj.browse(cr, uid, [uid])[0]
|
||||
|
||||
context['currency_id']=move.company_id.currency_id.id
|
||||
|
||||
qty = data['form']['move%s' % move.id]
|
||||
uom = data['form']['uom%s' % move.id]
|
||||
price = data['form']['price%s' % move.id]
|
||||
|
||||
Reference in New Issue
Block a user