Skip to content

Commit

Permalink
shopfloor_mobile: add icons to qty picker packagings
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Dec 19, 2023
1 parent 7d6cafb commit 79f7602
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def _packaging_parser(self):
"id",
("packaging_type_id:name", lambda rec, fname: rec.packaging_type_id.name),
("packaging_type_id:code", lambda rec, fname: rec.packaging_type_id.code),
("packaging_type_id:icon", self._packaging_icon_data),
"qty",
]

Expand Down Expand Up @@ -316,6 +317,15 @@ def _product_packaging(self, rec, field):
multi=True,
)

def _packaging_icon_data(self, rec, field):
icon_data = {"alt_text": "Icon for packaging " + rec.packaging_type_id.name}
if not rec.packaging_type_id.icon:
return icon_data
icon_data["url"] = "/web/image/product.packaging.type/{}/icon/".format(
rec.packaging_type_id.id
)
return icon_data

def _product_supplier_code(self, rec, field):
supplier_info = fields.first(
rec.seller_ids.filtered(lambda x: x.product_id == rec)
Expand Down
8 changes: 8 additions & 0 deletions shopfloor/actions/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def packaging(self):
"name": {"type": "string", "nullable": False, "required": True},
"code": {"type": "string", "nullable": True, "required": True},
"qty": {"type": "float", "required": True},
"icon": {
"type": "dict",
"required": False,
"schema": {
"url": {"type": "string", "required": False},
"alt_text": {"type": "string", "required": False},
},
},
}

def delivery_packaging(self):
Expand Down
2 changes: 1 addition & 1 deletion shopfloor/models/product_packaging_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
class ProductPackagingType(models.Model):
_inherit = "product.packaging.type"

icon = fields.Image()
icon = fields.Binary()
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,17 @@ export var PackagingQtyPicker = Vue.component("packaging-qty-picker", {
<v-col cols="2" md="2" v-if="!readonly">
<span class="qty-todo">/ {{ qty_todo_by_pkg[pkg.id] }}</span>
</v-col>
<v-col>
<v-col cols="4">
<div :class="qty_by_pkg[pkg.id] > 0 ? 'pkg-name font-weight-bold' : 'pkg-name'"> {{ pkg[pkgNameKey] }}</div>
<div v-if="contained_packaging[pkg.id]" :class="qty_by_pkg[pkg.id] > 0 ? 'pkg-qty font-weight-bold' : 'pkg-qty'">(x{{ contained_packaging[pkg.id].qty }} {{ contained_packaging[pkg.id].pkg.name }})</div>
</v-col>
<v-col cols="2" v-if="_.result(contained_packaging[pkg.id], 'pkg.icon.url', '')">
<img
class="qty-picker-packaging-icon"
:src="_.result(contained_packaging[pkg.id], 'pkg.icon.url', '')"
:alt="_.result(contained_packaging[pkg.id], 'pkg.icon.alt_text', '')"
/>
</v-col>
</v-row>
</v-expansion-panel-content>
</v-expansion-panel>
Expand Down
5 changes: 5 additions & 0 deletions shopfloor_mobile/static/wms/src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ I tested only w/ checkout/select_package for now
top: 5px;
right: 5px;
}

.qty-picker-packaging-icon {
width: 30px;
height: 30px;
}

0 comments on commit 79f7602

Please sign in to comment.