Fix `contract._load_available_email_ids` error
-
contract.py: If no parter is associated in a contract (ej: when manually creating a contract) when the contract method_load_available_emails_idgives an error, since the contract object has nopartner_idassociated 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