From 63dd8a5c3bdf2cbc127acc7847e8b3c4fe41f00a Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 23 Jun 2020 19:06:41 +0200 Subject: [PATCH] [IMP] raise exceptions when config NOK we need a level to fetch a tray we need the tray dimensions to point a cell --- stock_vertical_lift_kardex/models/stock_location.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/stock_vertical_lift_kardex/models/stock_location.py b/stock_vertical_lift_kardex/models/stock_location.py index 4f8a91983..cabf25775 100644 --- a/stock_vertical_lift_kardex/models/stock_location.py +++ b/stock_vertical_lift_kardex/models/stock_location.py @@ -3,7 +3,7 @@ import logging -from odoo import models +from odoo import _, exceptions, models _logger = logging.getLogger(__name__) @@ -12,6 +12,11 @@ class StockLocation(models.Model): _inherit = "stock.location" def _hardware_kardex_prepare_payload(self, cell_location=None): + if self.level is False: + raise exceptions.UserError( + _('Shuttle tray %s has no level. ' + 'Please fix the configuration') % self.display_name + ) message_template = ( "{code}|{hostId}|{addr}|{carrier}|{carrierNext}|" "{x}|{y}|{boxType}|{Q}|{order}|{part}|{desc}|\r\n" @@ -27,6 +32,12 @@ class StockLocation(models.Model): code = "61" # ping if cell_location: x, y = cell_location.tray_cell_center_position() + if x == 0 and y == 0: + raise exceptions.UserError( + _('Cell location %s has no position. ' + 'Check if the dimensions of tray %s ' + 'are properly set in the tray type.') % (cell_location.display_name, self.name) + ) else: x, y = "", "" subst = {