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

Module: Mail Whatsapp Gateway

Entity: mail.whatsapp.template.button

Compute Method: _compute_variable_ids

Inputs Method Outputs
dynamic_urls = self.filtered(
            lambda button: button.button_type == "url" and button.url_type == "dynamic"
        )
to_clear = self - dynamic_urls
for button in dynamic_urls:
            if button.variable_ids:
                button.variable_ids = [
                    (
                        1,
                        button.variable_ids[0].id,
                        {
                            "sample_value": button.website_url,
                            "line_type": "button",
                            "name": button.name,
                            "button_id": button.id,
                            "template_id": button.template_id.id,
                        },
                    ),
                ]
            else:
                button.variable_ids = [
                    (
                        0,
                        0,
                        {
                            "sample_value": button.website_url,
                            "line_type": "button",
                            "name": button.name,
                            "button_id": button.id,
                            "template_id": button.template_id.id,
                        },
                    ),
                ]
if to_clear:
            to_clear.variable_ids = [(5, 0)]

Back to entity