From d7438709203f87e65ee536b6299d6beb7362669f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 4 Jul 2016 14:49:22 +0200 Subject: [PATCH] [FIX] stock_account: change standard price in perpetual valuation When the standard price is changed for a product in perpetual valuation, the account used is the expense account on the product, while it should be the Counter-Part Account specified in the wizard. This adapts the commit 935e61bab5 to work with 40bd4a2f05. opw-681846 --- addons/stock_account/product.py | 6 +++--- addons/stock_account/wizard/stock_change_standard_price.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/stock_account/product.py b/addons/stock_account/product.py index 2e49d42d6d8..8572d670438 100644 --- a/addons/stock_account/product.py +++ b/addons/stock_account/product.py @@ -168,7 +168,7 @@ class product_product(osv.osv): self.valuation = 'manual_periodic' return {} - def do_change_standard_price(self, cr, uid, ids, new_price, context=None): + def do_change_standard_price(self, cr, uid, ids, new_price, account_id, context=None): """ Changes the Standard Price of Product and creates an account move accordingly.""" location_obj = self.pool.get('stock.location') move_obj = self.pool.get('account.move') @@ -190,11 +190,11 @@ class product_product(osv.osv): # Accounting Entries amount_diff = abs(diff * qty) if diff * qty > 0: - debit_account_id = datas['expense'].id + debit_account_id = account_id credit_account_id = datas['stock_valuation'].id else: debit_account_id = datas['stock_valuation'].id - credit_account_id = datas['expense'].id + credit_account_id = account_id lines = [(0, 0, {'name': _('Standard Price changed'), 'account_id': debit_account_id, diff --git a/addons/stock_account/wizard/stock_change_standard_price.py b/addons/stock_account/wizard/stock_change_standard_price.py index a90a9961694..340d2010699 100644 --- a/addons/stock_account/wizard/stock_change_standard_price.py +++ b/addons/stock_account/wizard/stock_change_standard_price.py @@ -66,6 +66,6 @@ class change_standard_price(osv.osv_memory): rec_ids = prod_obj.browse(cr, uid, rec_id, context=context).product_variant_ids.mapped('id') else: rec_ids = [rec_id] - prod_obj = self.pool.get('product.product') - prod_obj.do_change_standard_price(cr, uid, rec_ids, new_price, context) + res = self.browse(cr, uid, ids, context=context)[0] + self.pool.get('product.product').do_change_standard_price(cr, uid, rec_ids, new_price, res.counterpart_account_id.id, context=context) return {'type': 'ir.actions.act_window_close'}