Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Conditional Images

Entity: conditional.image.consumer.mixin

Compute Method: _compute_images

Inputs Method Outputs
if "company_id" in self._fields:
            search_clause = [("model_name", "=", self._name)]
        else:
            # If inherited object doesn't have a `company_id` field,
            # remove the items with a company defined and the related checks
            search_clause = [
                ("model_name", "=", self._name),
                ("company_id", "=", False),
            ]
conditional_images = self.env["conditional.image"].search(
            search_clause, order="company_id, selector"
        )
for record in self:
            images_found = conditional_images.filtered(
                lambda record, img: record._conditional_image_evaluate_selector(img)
            )
            values = {
                "image_1920": False,
                "image_1024": False,
                "image_512": False,
                "image_256": False,
                "image_128": False,
            }
            if images_found:
                image = images_found[0]
                values = {
                    "image_1920": image.image_1920,
                    "image_1024": image.image_1024,
                    "image_512": image.image_512,
                    "image_256": image.image_256,
                    "image_128": image.image_128,
                }
            record.update(values)

Back to entity