From 93881e7b3e34bf3fd21896794ab941d02a3da28f Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 14:48:12 +0200 Subject: [PATCH 1/8] bknd: map specific exceptions to odoo std exceptions We were losing the possibility to display the txt msg of the error because everything was wrapped by base_rest into InternalServerError. --- shopfloor/services/service.py | 55 +++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/shopfloor/services/service.py b/shopfloor/services/service.py index 877d561a45..35dbe6fcd5 100644 --- a/shopfloor/services/service.py +++ b/shopfloor/services/service.py @@ -28,6 +28,18 @@ def __init__(self, message, log_entry_url): self.rest_json_info = {"log_entry_url": log_entry_url} +class ShopfloorServiceUserErrorException( + ShopfloorServiceDispatchException, exceptions.UserError +): + """User error wrapped exception.""" + + +class ShopfloorServiceValidationErrorException( + ShopfloorServiceDispatchException, exceptions.ValidationError +): + """Validation error wrapped exception.""" + + class BaseShopfloorService(AbstractComponent): """Base class for REST services""" @@ -55,20 +67,45 @@ def _db_logging_active(self): def _dispatch_with_db_logging(self, method_name, _id=None, params=None): try: result = super().dispatch(method_name, _id=_id, params=params) - except Exception as err: - tb = traceback.format_exc() - self.env.cr.rollback() - with registry(self.env.cr.dbname).cursor() as cr: - env = self.env(cr=cr) - log_entry = self._log_call_in_db(env, request, _id, params, error=tb) - log_entry_url = self._get_log_entry_url(log_entry) - raise ShopfloorServiceDispatchException(str(err), log_entry_url) from err - + except exceptions.UserError as orig_exception: + self._dispatch_exception( + ShopfloorServiceUserErrorException, + orig_exception, + _id=_id, + params=params, + ) + except exceptions.ValidationError as orig_exception: + self._dispatch_exception( + ShopfloorServiceValidationErrorException, + orig_exception, + _id=_id, + params=params, + ) + except Exception as orig_exception: + self._dispatch_exception( + ShopfloorServiceDispatchException, + orig_exception, + _id=_id, + params=params, + ) log_entry = self._log_call_in_db(self.env, request, _id, params, result=result) log_entry_url = self._get_log_entry_url(log_entry) result["log_entry_url"] = log_entry_url return result + def _dispatch_exception( + self, exception_klass, orig_exception, _id=None, params=None + ): + tb = traceback.format_exc() + self.env.cr.rollback() + with registry(self.env.cr.dbname).cursor() as cr: + env = self.env(cr=cr) + log_entry = self._log_call_in_db(env, request, _id, params, error=tb) + log_entry_url = self._get_log_entry_url(log_entry) + # UserError and alike have `name` attribute to store the msg + exc_msg = getattr(orig_exception, "name", str(orig_exception)) + raise exception_klass(exc_msg, log_entry_url) from orig_exception + def _get_log_entry_url(self, entry): base_url = self.env["ir.config_parameter"].sudo().get_param("web.base.url") url_params = { From 4c70511f419fdbbe509536908df7d155c041acec Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 14:49:49 +0200 Subject: [PATCH 2/8] front: fix report url color for errors --- shopfloor_mobile/static/wms/src/css/main.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shopfloor_mobile/static/wms/src/css/main.css b/shopfloor_mobile/static/wms/src/css/main.css index aa7bed6eaf..e0f5456e95 100644 --- a/shopfloor_mobile/static/wms/src/css/main.css +++ b/shopfloor_mobile/static/wms/src/css/main.css @@ -356,6 +356,9 @@ ul.packaging span:first-child { .notifications p:last-child { margin-bottom: 0; } +.notifications > .v-alert.error a { + color: white; +} .searchform > .v-input:first-child { margin-top: 0; From fd0485ae461311d1f379b605cc876abf072a4090 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 14:51:14 +0200 Subject: [PATCH 3/8] front: fix defensive condition missing bknd data zone_picking.set_destination_all is buggy ATM and does not return move_line data when it asks to confirm the location. --- shopfloor_mobile/static/wms/src/scenario/zone_picking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js index 3da215ec0e..df9eae541f 100644 --- a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js @@ -148,7 +148,7 @@ const template_mobile = ` :card_color="utils.colors.color_for('screen_step_todo')" class="mt-2" /> -
+
From e258e7ba56e2cf4ebf66c904ee2abc84b0bf1ee1 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 16:09:13 +0200 Subject: [PATCH 4/8] front: fix qty picker packaging lost --- .../static/wms/src/components/packaging-qty-picker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopfloor_mobile/static/wms/src/components/packaging-qty-picker.js b/shopfloor_mobile/static/wms/src/components/packaging-qty-picker.js index b469f1d3b5..4c90234640 100644 --- a/shopfloor_mobile/static/wms/src/components/packaging-qty-picker.js +++ b/shopfloor_mobile/static/wms/src/components/packaging-qty-picker.js @@ -171,7 +171,7 @@ export var PackagingQtyPickerMixin = { if (!_.isEmpty(this.unit_uom)) { unit = [this.unit_uom]; } - return _.extend([], this.opts.available_packaging, unit); + return _.concat(this.opts.available_packaging, unit); }, /** * Sort packaging by qty and exclude the ones w/ qty = 0 From 56552712e5069e6cfea2bb0fd0e1d9fcc9f7b059 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 16:10:19 +0200 Subject: [PATCH 5/8] front: zone_picking fix summary group by dest pkg --- shopfloor_mobile/static/wms/src/scenario/zone_picking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js index df9eae541f..4c71c42c5b 100644 --- a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js @@ -340,7 +340,7 @@ export var ZonePicking = Vue.component("zone-picking", { // group_no_title: true, prepare_records: _.partialRight( this.utils.misc.group_by_pack, - "package_src" + "package_dest" ), }); }, From 5d231951008f3ac4d9a9f50238772c8c5182148e Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 16:11:02 +0200 Subject: [PATCH 6/8] front: cluter_picking scan dest qty default to 0 --- shopfloor_mobile/static/wms/src/scenario/cluster_picking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js index 2a5766bd8f..91c1d7d670 100644 --- a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js @@ -151,7 +151,7 @@ export var ClusterPicking = Vue.component("cluster-picking", { return { usage: "cluster_picking", initial_state_key: "start", - scan_destination_qty: 1, + scan_destination_qty: 0, states: { start: { on_get_work: evt => { From e07c24f93d6b983fc2da730fc087fce5108e7928 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 27 Aug 2020 16:32:30 +0200 Subject: [PATCH 7/8] front: zone_picking summary mark dest location as todo --- .../static/wms/src/scenario/zone_picking.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js index 4c71c42c5b..1d90c314e9 100644 --- a/shopfloor_mobile/static/wms/src/scenario/zone_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/zone_picking.js @@ -140,14 +140,6 @@ const template_mobile = ` :list_options="picking_summary_move_line_list_options([state.data.move_line])" :key="make_state_component_key(['picking-summary'])" /> -