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

Module: Product EPREL

Entity: product.template

Compute Method: _compute_eprel_url

Inputs Method Outputs
for rec in self:
            cat = rec.categ_id.eprel_category_id.code
            reg_num = rec.eprel_registration_number
            arrow_image_name = (
                rec.eprel_energy_class_image.replace(".svg", ".png")
                if rec.eprel_energy_class_image
                and isinstance(rec.eprel_energy_class_image, str)
                else False
            )
            lang_code = self.env.company.partner_id.lang.split("_")[0]
            rec.fiche_url = (
                f"{API_URL}fiches/{cat}/Fiche_{reg_num}_{lang_code.upper()}.pdf"
                if cat and reg_num
                else False
            )
            rec.label_url = (
                f"{API_URL}labels/{cat}/Label_{reg_num}.pdf"
                if cat and reg_num
                else False
            )
            rec.label_arrow_url = (
                "https://ec.europa.eu/assets/move-ener/eprel/"
                f"EPREL%20Public/Nested-labels%20thumbnails/{arrow_image_name}"
                if arrow_image_name
                else False
            )

Back to entity