Skip to content

Fix `contract._load_available_email_ids` error

Pelayo García requested to merge fix/contract_load_available_email_ids into master
  • contract.py: If no parter is associated in a contract (ej: when manually creating a contract) when the contract method _load_available_emails_id gives an error, since the contract object has no partner_id associated in which we can search the emails:
File "/opt/odoo_modules/somconnexio/models/contract.py", line 147, in _load_available_email_ids
    (6, 0, contract.partner_id.get_available_email_ids())

This suggestion empties the available email list if the contract has no associated partner.

  • contract_email_change.py:

The same happends when this line reaches the class _load_available_emails_id before self.partner_id is loaded:

defaults = super().default_get(fields_list)

The solution for both cases is check first that self.contract.partner_id or self.partner_id exist.

Edited by Pelayo García

Merge request reports