[FIX] stock_account: counterpart account of a cost price adjustment is more likely the expense account instead of the stock input/output. Backport of commit 57d0903154c562
This commit is contained in:
parent
4d8ec5f931
commit
077a168d4c
|
@ -129,14 +129,19 @@ class product_template(osv.osv):
|
|||
}
|
||||
move_id = move_obj.create(cr, uid, move_vals, context=context)
|
||||
|
||||
if diff*qty > 0:
|
||||
counterpart_account = product.property_account_expense and product.property_account_expense.id or False
|
||||
if not counterpart_account:
|
||||
counterpart_account = product.categ_id.property_account_expense_categ and product.categ_id.property_account_expense_categ.id or False
|
||||
if not counterpart_account:
|
||||
raise osv.except_osv(_('Error!'), _('No expense account defined on the product %s or on its category') % (product.name))
|
||||
if diff * qty > 0:
|
||||
amount_diff = qty * diff
|
||||
debit_account_id = datas['stock_account_input']
|
||||
debit_account_id = counterpart_account
|
||||
credit_account_id = datas['property_stock_valuation_account_id']
|
||||
else:
|
||||
amount_diff = qty * -diff
|
||||
debit_account_id = datas['property_stock_valuation_account_id']
|
||||
credit_account_id = datas['stock_account_output']
|
||||
credit_account_id = counterpart_account
|
||||
|
||||
move_line_obj.create(cr, uid, {
|
||||
'name': _('Standard Price changed'),
|
||||
|
|
Loading…
Reference in New Issue