diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index cd80a630e67..2b12106af38 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -285,7 +285,8 @@ class stock_move(osv.osv): average_valuation_price += q.qty * q.cost average_valuation_price = average_valuation_price / move.product_qty # Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products - product_obj.write(cr, SUPERUSER_ID, [move.product_id.id], {'standard_price': average_valuation_price}, context=context) + ctx = dict(context, force_company=move.company_id.id) + product_obj.write(cr, SUPERUSER_ID, [move.product_id.id], {'standard_price': average_valuation_price}, context=ctx) self.write(cr, uid, [move.id], {'price_unit': average_valuation_price}, context=context) def product_price_update_before_done(self, cr, uid, ids, context=None): @@ -310,7 +311,8 @@ class stock_move(osv.osv): new_std_price = ((amount_unit * product_avail) + (move.price_unit * move.product_qty)) / (product_avail + move.product_qty) tmpl_dict[prod_tmpl_id] += move.product_qty # Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products - product_obj.write(cr, SUPERUSER_ID, [product.id], {'standard_price': new_std_price}, context=context) + ctx = dict(context or {}, force_company=move.company_id.id) + product_obj.write(cr, SUPERUSER_ID, [product.id], {'standard_price': new_std_price}, context=ctx) def product_price_update_after_done(self, cr, uid, ids, context=None): ''' diff --git a/openerp/addons/base/res/ir_property.py b/openerp/addons/base/res/ir_property.py index f14c68d06d3..382f7ae2b95 100644 --- a/openerp/addons/base/res/ir_property.py +++ b/openerp/addons/base/res/ir_property.py @@ -226,7 +226,7 @@ class ir_property(osv.osv): # retrieve the properties corresponding to the given record ids self._cr.execute("SELECT id FROM ir_model_fields WHERE name=%s AND model=%s", (name, model)) field_id = self._cr.fetchone()[0] - company_id = self.env['res.company']._company_default_get(model, field_id) + company_id = self.env.context.get('force_company') or self.env['res.company']._company_default_get(model, field_id) refs = {('%s,%s' % (model, id)): id for id in values} props = self.search([ ('fields_id', '=', field_id),