From fda31b9d8abf34f96b1b26fd93fef650fcf04766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Wed, 22 Apr 2015 22:05:57 +0300 Subject: [PATCH] Catch value error in case view isn't yet loaded --- quantity_warn_on_lot/models/stock_move_split.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/quantity_warn_on_lot/models/stock_move_split.py b/quantity_warn_on_lot/models/stock_move_split.py index b301c2c6f4f3..1874c9e2cfff 100644 --- a/quantity_warn_on_lot/models/stock_move_split.py +++ b/quantity_warn_on_lot/models/stock_move_split.py @@ -19,10 +19,13 @@ # along with this program. If not, see . # ############################################################################## +import logging from openerp.osv import orm from openerp.tools.translate import _ +_logger = logging.getLogger(__name__) + class InvalidAmountException(Exception): @@ -55,9 +58,15 @@ class StockMoveSplit(orm.TransientModel): def get_confirm_view_id(self, cr, uid, context=None): """Get the default view id for the confirm view.""" ir_model_data = self.pool.get('ir.model.data') - view_ref = ir_model_data.get_object_reference( - cr, uid, 'quantity_warn_on_lot', 'view_confirm_split' - ) + + try: + view_ref = ir_model_data.get_object_reference( + cr, uid, 'quantity_warn_on_lot', 'view_confirm_split' + ) + except ValueError as exc: + _logger.debug(exc) + view_ref = None + return view_ref and view_ref[1] or False def restore_split(self, cr, uid, ids, context=None):