[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
This commit is contained in:
Nicolas Martinelli
2016-07-04 14:49:22 +02:00
parent c5cf412c10
commit d743870920
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -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,
@@ -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'}