[FIX] stock_account: average cost in multi-company environment
When receiving goods with average price set as costing method, for a move from another company than the SUPERUSER_id company, the average price updated was the one from the SUPERUSER company instead of the one of the move. opw-634167
This commit is contained in:
parent
187ad0a054
commit
a4c7c564cf
|
@ -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):
|
||||
'''
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue