[FIX] stock_account: raise proper error when the valuation accounts aren't set on the product category while trying to process a stock move for a product in perpetual valuation. Fixes #8873

This commit is contained in:
qdp-odoo
2015-10-16 09:41:25 +02:00
parent 1456262801
commit af0f33a475
+7
View File
@@ -271,6 +271,12 @@ class stock_quant(osv.osv):
acc_valuation = acc_valuation.id
if not accounts.get('stock_journal', False):
raise UserError(_('You don\'t have any stock journal defined on your product category, check if you have installed a chart of accounts'))
if not acc_src:
raise UserError(_('Cannot find a stock input account for the product %s. You must define one on the product category, or on the location, before processing this operation.') % (move.product_id.name))
if not acc_dest:
raise UserError(_('Cannot find a stock output account for the product %s. You must define one on the product category, or on the location, before processing this operation.') % (move.product_id.name))
if not acc_valuation:
raise UserError(_('You don\'t have any stock valuation account defined on your product category. You must define one before processing this operation.'))
journal_id = accounts['stock_journal'].id
return journal_id, acc_src, acc_dest, acc_valuation
@@ -292,6 +298,7 @@ class stock_quant(osv.osv):
#the standard_price of the product may be in another decimal precision, or not compatible with the coinage of
#the company currency... so we need to use round() before creating the accounting entries.
valuation_amount = currency_obj.round(cr, uid, move.company_id.currency_id, valuation_amount * qty)
#check that all data is correct
if move.company_id.currency_id.is_zero(valuation_amount):
raise UserError(_("The found valuation amount for product %s is zero. Which means there is probably a configuration error. Check the costing method and the standard price") % (move.product_id.name,))
partner_id = (move.picking_id.partner_id and self.pool.get('res.partner')._find_accounting_partner(move.picking_id.partner_id).id) or False