From af0f33a4759b8f3adfd7f9a448be5f63994e9f1f Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Fri, 16 Oct 2015 09:41:25 +0200 Subject: [PATCH] [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 --- addons/stock_account/stock_account.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 0cf01628a92..08861ab5d2c 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -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