Skip to content

Commit

Permalink
FIXME FIXME
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Dec 1, 2023
1 parent 7732944 commit 5797802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion shopfloor/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
)

Expand Down
1 change: 1 addition & 0 deletions shopfloor/actions/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5797802

Please sign in to comment.