From 57978026db5650e0d77a74fa997584a128626c22 Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Fri, 1 Dec 2023 14:04:15 +0100 Subject: [PATCH] FIXME FIXME --- shopfloor/actions/data.py | 10 +++++++++- shopfloor/actions/schema.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shopfloor/actions/data.py b/shopfloor/actions/data.py index aaefbc06dc2..7d0bd84d1e4 100644 --- a/shopfloor/actions/data.py +++ b/shopfloor/actions/data.py @@ -5,6 +5,8 @@ from odoo.addons.component.core import Component from odoo.addons.shopfloor_base.utils import ensure_model +import base64 + class DataAction(Component): _inherit = "shopfloor.data.action" @@ -151,6 +153,7 @@ def packaging_list(self, record, **kw): def _packaging_parser(self): return [ "id", + ("packaging_type_id:icon", lambda rec, fname: base64.b64decode(rec.packaging_type_id.icon or b'')), ("packaging_type_id:name", lambda rec, fname: rec.packaging_type_id.name), ("packaging_type_id:code", lambda rec, fname: rec.packaging_type_id.code), "qty", @@ -310,9 +313,14 @@ def _product_parser(self): ] def _product_packaging(self, rec, field): + _packaging_parser = self._packaging_parser + for item in _packaging_parser: + if "packaging_type_id:icon" in item: + item = ("packaging_type_id:icon", lambda record, fname: base64.b64encode(record.packaging_type_id.icon or b'').decode("utf-8")) + break return self._jsonify( rec.packaging_ids.filtered(lambda x: x.qty), - self._packaging_parser, + _packaging_parser, multi=True, ) diff --git a/shopfloor/actions/schema.py b/shopfloor/actions/schema.py index bfa0fdba4e7..d252a00f4ed 100644 --- a/shopfloor/actions/schema.py +++ b/shopfloor/actions/schema.py @@ -135,6 +135,7 @@ def packaging(self): "name": {"type": "string", "nullable": False, "required": True}, "code": {"type": "string", "nullable": True, "required": True}, "qty": {"type": "float", "required": True}, + "icon": {"type": "binary", "required": False}, } def delivery_packaging(self):