Skip to content

Commit

Permalink
Merge branch 'ui-imp-fix' into 13.0-shopfloor
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed May 29, 2020
2 parents c29dbdc + 49dc4ac commit 3121235
Show file tree
Hide file tree
Showing 38 changed files with 820 additions and 291 deletions.
20 changes: 15 additions & 5 deletions shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def _jsonify(self, recordset, parser, multi=False, **kw):
return res[0] if res else None
return res

def _simple_record_parser(self):
return ["id", "name"]

def partner(self, record, **kw):
return self._jsonify(record, self._partner_parser, **kw)

Expand All @@ -26,7 +29,7 @@ def partners(self, record, **kw):

@property
def _partner_parser(self):
return ["id", "name"]
return self._simple_record_parser()

def location(self, record, **kw):
return self._jsonify(
Expand Down Expand Up @@ -95,12 +98,12 @@ def _package_packaging_parser(self):
def packaging(self, record, **kw):
return self._jsonify(record, self._packaging_parser, **kw)

def packagings(self, record, **kw):
def packaging_list(self, record, **kw):
return self.packaging(record, multi=True)

@property
def _packaging_parser(self):
return ["id", "name"]
return self._simple_record_parser() + ["qty"]

def lot(self, record, **kw):
return self._jsonify(record, self._lot_parser, **kw)
Expand All @@ -110,7 +113,7 @@ def lots(self, record, **kw):

@property
def _lot_parser(self):
return ["id", "name", "ref"]
return self._simple_record_parser() + ["ref"]

def move_line(self, record, **kw):
record = record.with_context(location=record.location_id.id)
Expand Down Expand Up @@ -153,7 +156,14 @@ def products(self, record, **kw):

@property
def _product_parser(self):
return ["id", "name", "display_name", "default_code", "barcode"]
return [
"id",
"name",
"display_name",
"default_code",
"barcode",
("packaging_ids:packaging", self._packaging_parser),
]

def picking_batch(self, record, with_pickings=False, **kw):
parser = self._picking_batch_parser
Expand Down
4 changes: 2 additions & 2 deletions shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _response_for_change_packaging(self, picking, package, packaging_list):
"package": self.data_struct.package(
package, picking=picking, with_packaging=True
),
"packagings": self.data_struct.packagings(packaging_list.sorted()),
"packaging": self.data_struct.packaging_list(packaging_list.sorted()),
},
)

Expand Down Expand Up @@ -1229,7 +1229,7 @@ def _schema_select_packaging(self):
"type": "dict",
"schema": self.schemas.package(with_packaging=True),
},
"packagings": {
"packaging": {
"type": "list",
"schema": {"type": "dict", "schema": self.schemas.packaging()},
},
Expand Down
9 changes: 3 additions & 6 deletions shopfloor/services/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def product(self):
"display_name": {"type": "string", "nullable": False, "required": True},
"default_code": {"type": "string", "nullable": False, "required": True},
"barcode": {"type": "string", "nullable": True, "required": False},
"packaging": self._schema_list_of(self.packaging()),
}

def package(self, with_packaging=False):
Expand All @@ -122,12 +123,7 @@ def package(self, with_packaging=False):
"move_line_count": {"required": False, "nullable": True, "type": "integer"},
}
if with_packaging:
schema["packaging"] = {
"type": "dict",
"required": True,
"nullable": True,
"schema": self.packaging(),
}
schema["packaging"] = self._schema_dict_of(self.packaging())
return schema

def lot(self):
Expand All @@ -148,6 +144,7 @@ def packaging(self):
return {
"id": {"required": True, "type": "integer"},
"name": {"type": "string", "nullable": False, "required": True},
"qty": {"type": "float", "required": True},
}

def picking_batch(self, with_pickings=False):
Expand Down
15 changes: 11 additions & 4 deletions shopfloor/tests/test_actions_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,22 @@ def _expected_product(self, record, **kw):
"display_name": record.display_name,
"default_code": record.default_code,
"barcode": record.barcode,
"packaging": [self._expected_packaging(x) for x in record.packaging_ids],
}

def _expected_packaging(self, record, **kw):
return {
"id": record.id,
"name": record.name,
"qty": record.qty,
}


class ActionsDataCase(ActionsDataCaseBase):
def test_data_packaging(self):
data = self.data.packaging(self.packaging)
self.assert_schema(self.schema.packaging(), data)
expected = {"id": self.packaging.id, "name": self.packaging.name}
self.assertDictEqual(data, expected)
self.assertDictEqual(data, self._expected_packaging(self.packaging))

def test_data_location(self):
location = self.stock_location
Expand Down Expand Up @@ -107,8 +114,8 @@ def test_data_package(self):
"id": package.id,
"name": package.name,
"move_line_count": 1,
"packaging": self.data.packaging(package.product_packaging_id),
"weight": 0,
"packaging": self._expected_packaging(package.product_packaging_id),
"weight": 0.0,
}
self.assertDictEqual(data, expected)

Expand Down
3 changes: 1 addition & 2 deletions shopfloor/tests/test_actions_data_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ def test_data_location(self):
def test_data_packaging(self):
data = self.data_detail.packaging(self.packaging)
self.assert_schema(self.schema_detail.packaging(), data)
expected = {"id": self.packaging.id, "name": self.packaging.name}
self.assertDictEqual(data, expected)
self.assertDictEqual(data, self._expected_packaging(self.packaging))

def test_data_lot(self):
lot = self.env["stock.production.lot"].create(
Expand Down
1 change: 1 addition & 0 deletions shopfloor_mobile/static/wms/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<script src="src/components/list.js" type="module"></script>
<script src="src/components/manual_select.js"></script>
<script src="src/components/input-number-spinner.js" type="module"></script>
<script src="src/components/packaging-qty-picker.js" type="module"></script>
<script src="src/components/detail/detail_mixin.js" type="module"></script>
<script src="src/components/detail/detail_card.js" type="module"></script>
<script src="src/components/detail/detail_location.js" type="module"></script>
Expand Down
46 changes: 24 additions & 22 deletions shopfloor_mobile/static/wms/src/components/batch_picking_detail.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable strict */
Vue.component("batch-picking-detail", {
props: ["info"],
props: ["record"],
methods: {
detail_fields() {
return [
Expand All @@ -17,36 +17,38 @@ Vue.component("batch-picking-detail", {
},
},
template: `
<div class="detail batch-picking-detail with-bottom-actions" v-if="!_.isEmpty(info)">
<div>
<div class="detail batch-picking-detail with-bottom-actions" v-if="!_.isEmpty(record)">
<item-detail-card :record="info" :options="{main: true, loud: true, fields: detail_fields()}">
<div class="review">
</item-detail-card>
<item-detail-card :card_color="utils.colors.color_for('screen_step_todo')"
:record="record" :options="{main: true, loud: true, fields: detail_fields()}" />
<separator-title>Pickings</separator-title>
<div class="button-list button-vertical-list full">
<v-row align="center">
<v-col class="text-center" cols="12">
<btn-action @click="$emit('confirm')">Start</btn-action>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<btn-action :action="'cancel'" @click="$emit('cancel')">Cancel</btn-action>
</v-col>
</v-row>
</div>
</div>
<div class="pickings">
<separator-title>Pickings list</separator-title>
<detail-picking
v-for="picking in info.pickings"
v-for="picking in record.pickings"
:key="picking.id"
:picking="picking"
:klass="'listed'"
:record="picking"
:options="{fields: picking_detail_fields()}"
/>
</div>
<div class="button-list button-vertical-list full">
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn color="primary" @click="$emit('confirm')">Start</v-btn>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn color="error" @click="$emit('cancel')">Cancel</v-btn>
</v-col>
</v-row>
</div>
</div>
`,
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
export var batch_picking_line = Vue.component("batch-picking-line-detail", {
props: {
line: Object,
// TODO: not sure this is still needed
showFullInfo: {
articleScanned: {
type: Boolean,
default: true,
default: false,
},
articleScanned: {
showQtyPicker: {
type: Boolean,
default: false,
},
Expand All @@ -22,18 +21,6 @@ export var batch_picking_line = Vue.component("batch-picking-line-detail", {
},
},
methods: {
detail_fields(key) {
const mapping = {
location_src: [],
product: [
{path: "package_src.name", label: "Pack"},
{path: "quantity", label: "Qty"},
{path: "product.qty_available", label: "Qty on hand"},
],
location_dest: [],
};
return mapping[key];
},
full_detail_fields() {
return [
{path: "batch.name", label: "Batch"},
Expand All @@ -50,37 +37,41 @@ export var batch_picking_line = Vue.component("batch-picking-line-detail", {
<item-detail-card
:key="'batch-picking-line-detail-1'"
:record="line"
:options="{main: true, key_title: 'location_src.name', fields: detail_fields('location_src')}"
:card_color="$root.colors.color_for('screen_step_done')"
:options="{main: true, key_title: 'location_src.name', title_action_field: {action_val_path: 'location_src.barcode'}}"
:card_color="utils.colors.color_for('screen_step_done')"
/>
<item-detail-card
:key="'batch-picking-line-detail-2'"
:record="line"
:options="{main: true, key_title: 'product.display_name', fields: detail_fields('product')}"
:card_color="$root.colors.color_for(articleScanned ? 'screen_step_done': 'screen_step_missing')"
:options="utils.misc.move_line_product_detail_options()"
:card_color="utils.colors.color_for(articleScanned ? 'screen_step_done': 'screen_step_todo')"
/>
<item-detail-card
v-if="articleScanned && has_destination_pack"
:key="'batch-picking-line-detail-3'"
:record="line"
:options="{main: true, key_title: 'package_dest.name'}"
:card_color="$root.colors.color_for(has_destination_pack ? 'screen_step_done': 'screen_step_missing')"
:options="{main: true, key_title: 'package_dest.name', title_action_field: {action_val_path: 'package_dest.name'}}"
:card_color="utils.colors.color_for(has_destination_pack ? 'screen_step_done': 'screen_step_todo')"
/>
<v-card class="pa-2" :color="utils.colors.color_for('screen_step_todo')" v-if="showQtyPicker">
<packaging-qty-picker :options="utils.misc.move_line_qty_picker_options(line)" />
</v-card>
<item-detail-card
v-if="articleScanned && !has_destination_pack"
:key="'batch-picking-line-detail-4'"
:record="line"
:options="{main: true}"
:card_color="$root.colors.color_for(has_destination_pack ? 'screen_step_done': 'screen_step_missing')"
:options="{main: true, title_action_field: {action_val_path: 'name'}}"
:card_color="utils.colors.color_for(has_destination_pack ? 'screen_step_done': 'screen_step_todo')"
>
<template v-slot:title>
Destination pack not selected.
</template>
</item-detail-card>
<!--
<v-expansion-panels>
<v-expansion-panel class="with-card">
<v-expansion-panel-header>Full details</v-expansion-panel-header>
Expand All @@ -93,8 +84,7 @@ export var batch_picking_line = Vue.component("batch-picking-line-detail", {
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<todo>Missing package qty widget</todo>
-->
</div>
`,
Expand All @@ -120,7 +110,7 @@ export var batch_picking_line_actions = Vue.component("batch-picking-line-action
<div class="button-list button-vertical-list full">
<v-row class="actions bottom-actions">
<v-col class="text-center" cols="12">
<v-btn color="primary" dark v-on="on">Action</v-btn>
<btn-action v-on="on">Action</btn-action>
</v-col>
</v-row>
</div>
Expand All @@ -129,28 +119,28 @@ export var batch_picking_line_actions = Vue.component("batch-picking-line-action
<div class="button-list button-vertical-list full">
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="primary" @click="handle_action('action_full_bin')">Go to destination - full bin(s)</v-btn>
<btn-action @click="handle_action('action_full_bin')">Go to destination - full bin(s)</btn-action>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="primary" @click="handle_action('action_skip_line')">Skip line</v-btn>
<btn-action @click="handle_action('action_skip_line')">Skip line</btn-action>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="primary"
@click="handle_action('action_stock_out')">Declare stock out</v-btn>
<btn-action
@click="handle_action('action_stock_out')">Declare stock out</btn-action>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="primary" @click="handle_action('action_change_pack_or_lot')">Change lot or pack</v-btn>
<btn-action @click="handle_action('action_change_pack_or_lot')">Change lot or pack</btn-action>
</v-col>
</v-row>
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="secondary" @click="dialog = false">Back</v-btn>
<v-btn x-large @click="dialog = false">Back</v-btn>
</v-col>
</v-row>
</div>
Expand All @@ -171,11 +161,11 @@ export var batch_picking_line_stock_out = Vue.component(
},
template: `
<div class="batch-picking-line-stock-out">
<batch-picking-line-detail :line="line" :showFullInfo="false" />
<batch-picking-line-detail :line="line" />
<div class="button-list button-vertical-list full">
<v-row align="center">
<v-col class="text-center" cols="12">
<v-btn x-large color="primary" @click="handle_action('confirm_stock_issue')">Confirm stock = 0</v-btn>
<btn-action @click="handle_action('confirm_stock_issue')">Confirm stock = 0</btn-action>
</v-col>
</v-row>
<v-row align="center">
Expand Down
Loading

0 comments on commit 3121235

Please sign in to comment.