add pos_attribute_image_lazy
This commit is contained in:
parent
83146e83ff
commit
e2680b250f
5 changed files with 81 additions and 0 deletions
1
pos_attribute_image_lazy/models/__init__.py
Normal file
1
pos_attribute_image_lazy/models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import pos_session
|
||||
27
pos_attribute_image_lazy/models/pos_session.py
Normal file
27
pos_attribute_image_lazy/models/pos_session.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from odoo import models
|
||||
|
||||
|
||||
class PosSession(models.Model):
|
||||
_inherit = "pos.session"
|
||||
|
||||
def _get_attributes_by_ptal_id(self):
|
||||
"""Return the attribute values without inlining their image content.
|
||||
|
||||
``point_of_sale`` reads the ``image`` field of every
|
||||
``product.attribute.value`` belonging to a ``no_variant`` attribute and
|
||||
ships it, base64 encoded, inside the ``load_pos_data`` response --
|
||||
repeated once per attribute line using that value.
|
||||
|
||||
The POS front end never uses those bytes: the only reader is
|
||||
``point_of_sale.ColorProductAttribute``, which merely tests the field
|
||||
for truthiness and then renders the swatch from
|
||||
``/web/image/product.template.attribute.value/<id>/image``.
|
||||
|
||||
Reading with ``bin_size`` makes the ORM return the human readable
|
||||
attachment size (e.g. ``b'827.41 Kb'``) instead of its content, so the
|
||||
attachment is never loaded into memory. The value stays truthy, which
|
||||
keeps the swatch rendering identical.
|
||||
"""
|
||||
return super(
|
||||
PosSession, self.with_context(bin_size=True)
|
||||
)._get_attributes_by_ptal_id()
|
||||
Loading…
Add table
Add a link
Reference in a new issue