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

Module: Sendcloud Shipping

Entity: sendcloud.shipping.method.country

Compute Method: _compute_price_custom

Inputs Method Outputs
isos = self.mapped("iso_2")
companies = self.mapped("company_id")
method_codes = self.mapped("method_code")
custom_items = self.env["sendcloud.shipping.method.country.custom"].search(
            [
                ("iso_2", "in", isos),
                ("company_id", "in", companies.ids),
                ("method_code", "in", method_codes),
            ],
        )
for item in self:
            custom = custom_items.filtered(
                lambda ci, i=item: ci.iso_2 == i.iso_2
                and ci.method_code == i.method_code
                and ci.company_id == i.company_id
            )
            if custom:
                item.price_check = "custom"
                item.enable_price_custom = custom[0].enable_price_custom
                if custom[0].enable_price_custom:
                    item.price_custom = custom[0].price
                else:
                    item.price_custom = item.price
                item.product_id = custom[0].product_id
            else:
                item.price_custom = item.price
                item.price_check = "standard"

Back to entity