Files
odoo_source/addons/pos_self_order/models
Zachary Hanham 5db82daa8d [FIX] pos_self_order: use stored fields to check if product "has_image"
For method `_get_product_for_ui` in pos_self_order's product.product extension, check fields `product_tmpl_id.image_128` and/or `image_variant_128` for the existance of an image on the product (`has_image` key).

Previously, the field `image_1920` was used which has two issues:

1.) The 128 sized image should be preferred because it is 15x smaller than 1920. The whole image is loaded at this point, so the smallest-sized one should be used.

2.) `image_1920` is a computed, non-stored, field. This has the implication that the image will be processed, thus consuming more memory (even leading to a MemoryError on the customer's DB). This happens like so:
	a.) `_compute_image_1920` is called, which sets a value into `record.image_1920`. https://github.com/odoo/odoo/blob/38f37edad3da4a4547b73d971e053b0634067fa1/addons/product/models/product_product.py#L157
	b.) Eventually `_image_process` is called, which performs memory intensive computations on the image. https://github.com/odoo/odoo/blob/38f37edad3da4a4547b73d971e053b0634067fa1/odoo/fields.py#L2550

So this can be avoided by implementing this commit, which will check the stored, non-computed fields instead.

Memory benchmarks for allocations by `_get_self_order_data`:

Done on customer DB with 1340 product.products, with a total of 776 images between them.

Before commit: 1638.4 MiB + server memory limit reached

After commit: 29.7 MiB total

Total improvement of 55x less memory usage

closes odoo/odoo#157900

Signed-off-by: Vlad Stroia (vlst) <vlst@odoo.com>
2024-03-22 14:47:53 +00:00
..