|
|
for partner in self:
stored_identifiers = partner.additional_identifiers or {}
vals = {
# Resolve lazy translations now: JSON would otherwise stringify them in a frame where
# no language can be detected.
key: self._lazy_translate_additional_identifiers_metadata(metadata)
for key, metadata in self._get_all_additional_identifiers_metadata().items()
if not metadata.get('countries')
or partner.country_code in metadata['countries']
or key in stored_identifiers # includes international, and any identifier already set on the record
}
if {key: metadata for key, metadata in vals.items() if metadata.get('category') == 'EN' and key != 'OTHER'}:
# Pops out the default 'OTHER' only if another 'EN' identifier is available
vals.pop('OTHER', None)
partner.available_additional_identifiers_metadata = vals
|
|