Search code examples
pythonodoo-13

What is the purpose of address_get?


Please tell me what is the purpose of address_get()? Why we use this? Here in the sales module "sale.py", it is used as:

addr = self.partner_id.address_get(['delivery', 'invoice'])

Solution

  • It is used to find needed addresses from three structure.

    From Source:

    Find contacts/addresses of the right type(s) by doing a depth-first-search through descendants within company boundaries (stop at entities flagged is_company) then continuing the search at the ancestors that are within the same company boundaries. Defaults to partners of type 'default' when the exact type is not found, or to the provided partner itself if no type 'default' is found either.

    https://github.com/odoo/odoo/blob/ce6f6fb4e04746d28e1b959d50f50a855c7a3049/odoo/addons/base/models/res_partner.py#L855