Skip to content

Commit

Permalink
Merge pull request #55 from simahawk/13.0-shopfloor
Browse files Browse the repository at this point in the history
Misc fixes/imp
  • Loading branch information
simahawk authored Aug 28, 2020
2 parents 033b919 + d630314 commit b25783a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 23 deletions.
55 changes: 46 additions & 9 deletions shopfloor/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions shopfloor_mobile/static/wms/src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
19 changes: 7 additions & 12 deletions shopfloor_mobile/static/wms/src/scenario/zone_picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,7 @@ const template_mobile = `
:list_options="picking_summary_move_line_list_options([state.data.move_line])"
:key="make_state_component_key(['picking-summary'])"
/>
<item-detail-card
v-if="state.data.move_line"
:key="make_state_component_key(['detail-move-line-dest-pack', state.data.move_line.id])"
:record="state.data.move_line"
:options="{main: true, key_title: 'package_dest.name'}"
:card_color="utils.colors.color_for('screen_step_todo')"
class="mt-2"
/>
<div class="no-line-found" v-if="state.data.move_line">
<div class="no-line-found" v-if="_.isEmpty(state.data.move_line)">
<!-- In theory this should not happen.
Handled only because something seems wrong backend side
and we might get here w/ no line info. -->
Expand Down Expand Up @@ -340,8 +332,11 @@ export var ZonePicking = Vue.component("zone-picking", {
// group_no_title: true,
prepare_records: _.partialRight(
this.utils.misc.group_by_pack,
"package_src"
"package_dest"
),
group_color_maker: function(lines) {
return "screen_step_todo";
},
});
},
picking_summary_move_line_list_options: function(move_lines) {
Expand Down Expand Up @@ -515,7 +510,7 @@ export var ZonePicking = Vue.component("zone-picking", {
this.odoo.call("unload_scan_pack", {
zone_location_id: this.current_zone_location().id,
picking_type_id: this.current_picking_type().id,
package_id: this.state.data.move_line.package_src.id,
package_id: this.state.data.move_line.package_dest.id,
barcode: scanned.text,
})
);
Expand All @@ -531,7 +526,7 @@ export var ZonePicking = Vue.component("zone-picking", {
this.odoo.call("unload_set_destination", {
zone_location_id: this.current_zone_location().id,
picking_type_id: this.current_picking_type().id,
package_id: this.state.data.move_line.package_src.id,
package_id: this.state.data.move_line.package_dest.id,
barcode: scanned.text,
confirmation: this.state.data.confirmation_required,
})
Expand Down

0 comments on commit b25783a

Please sign in to comment.