[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 commit935e61bab5to work with40bd4a2f05. opw-681846
This commit is contained in:
@@ -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'}
|
||||
|
||||
Reference in New Issue
Block a user