Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] shopfloor_mobile: display pickings by priority in checkout #782

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DataAction(Component):
def location(self, record, **kw):
parser = self._location_parser
data = self._jsonify(record.with_context(location=record.id), parser, **kw)
if "with_operation_progress" in kw:
if kw.get("with_operation_progress"):
lines_blacklist = (
kw.get("progress_lines_blacklist")
or self.env["stock.move.line"].browse()
Expand Down Expand Up @@ -46,7 +46,7 @@ def _get_picking_parser(self, record, **kw):
# and it may reduce performance significatively
# when dealing with a large number of pickings.
# Thus, we make it optional.
if "with_progress" in kw:
if kw.get("with_progress"):
parser.append("progress")
return parser

Expand All @@ -72,6 +72,7 @@ def _picking_parser(self, **kw):
"bulk_line_count",
"total_weight:weight",
"scheduled_date",
"priority",
]

@ensure_model("stock.quant.package")
Expand Down
1 change: 1 addition & 0 deletions shopfloor/actions/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def picking(self):
"scheduled_date": {"type": "string", "nullable": False, "required": True},
"progress": {"type": "float", "nullable": True},
"location_dest": self._schema_dict_of(self.location(), required=False),
"priority": {"type": "string", "nullable": True, "required": False},
}

def move_line(self, with_packaging=False, with_picking=False):
Expand Down
2 changes: 1 addition & 1 deletion shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def _domain_for_list_stock_picking(self):
]

def _order_for_list_stock_picking(self):
return "scheduled_date asc, id asc"
return "priority desc, scheduled_date asc, id asc"

def list_stock_picking(self):
"""List stock.picking records available
Expand Down
2 changes: 2 additions & 0 deletions shopfloor/tests/test_actions_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_data_picking(self):
"partner": {"id": self.customer.id, "name": self.customer.name},
"carrier": {"id": carrier.id, "name": carrier.name},
"ship_carrier": None,
"priority": "0",
}
self.assertEqual(data.pop("scheduled_date").split("T")[0], "2020-08-03")
self.assertDictEqual(data, expected)
Expand All @@ -179,6 +180,7 @@ def test_data_picking_with_progress(self):
"carrier": {"id": carrier.id, "name": carrier.name},
"ship_carrier": None,
"progress": 0.0,
"priority": "0",
}
self.assertEqual(data.pop("scheduled_date").split("T")[0], "2020-08-03")
self.assertDictEqual(data, expected)
Expand Down
1 change: 1 addition & 0 deletions shopfloor/views/shopfloor_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
name="scan_location_or_pack_first"
attrs="{'invisible': [('scan_location_or_pack_first_is_possible', '=', False)]}"
>
<field name="scenario_key" invisible="1" />
<field name="scan_location_or_pack_first_is_possible" invisible="1" />
<field name="scan_location_or_pack_first" />
<div
Expand Down
14 changes: 14 additions & 0 deletions shopfloor_mobile/static/wms/src/scenario/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,20 @@ const Checkout = {
{path: "origin"},
{path: "carrier.name", label: "Carrier"},
{path: "move_line_count", label: "Lines"},
{
path: "priority",
render_component: "priority-widget",
render_options: function (record) {
const priority = parseInt(record.priority);
// We need to pass the label to the component as an option instead of using "display_no_value"
JuMiSanAr marked this conversation as resolved.
Show resolved Hide resolved
// because pickings with no priority will still have a string value of "0"
// and the label would always be displayed.
return {
priority,
label: priority ? "Priority: " : null,
};
},
},
],
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export var PriorityWidget = Vue.component("priority-widget", {
},
template: `
<div :class="[$options._componentTag, opts.mode ? 'mode-' + opts.mode: '', 'd-inline']">
<span v-if="opts.label">{{ opts.label }}</span>
<span v-for="n in _.range(1, opts.priority + 1)" v-if="opts.priority" :class="['priority-' + n]">
<v-icon color="amber accent-2">mdi-star</v-icon>
</span>
Expand Down
Loading