[FIX] base: Invalid parent_id field in crm.lead for Mexico

Issue

    - Change country to Mexico
    - Install 'CRM'
    - Install 'l10n_mx_edi'
    - Try to open any lead in 'CRM'

    The same error is present in l10n_pe

Cause

    'l10n_mx_edi' and 'l10n_pe' use 'res.partner' in 'ir.ui.view'

Solution

    Adding a condition to prevent '_fields_view_get_address' in 'format.address.mixin'
    from rewritting the model and let ir.ui.view determine it

opw-2361875

closes odoo/odoo#60463

X-original-commit: 3229239c2a738cc99820dba0fce1bd1c2a3536ea
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
This commit is contained in:
Achraf (abz)
2020-10-21 14:40:12 +00:00
parent 7e26237ffe
commit e37b0707e6
+1 -1
View File
@@ -48,7 +48,7 @@ class FormatAddressMixin(models.AbstractModel):
def _fields_view_get_address(self, arch):
# consider the country of the user, not the country of the partner we want to display
address_view_id = self.env.company.country_id.address_view_id
if address_view_id and not self._context.get('no_address_format'):
if address_view_id and not self._context.get('no_address_format') and (not address_view_id.model or address_view_id.model == self._name):
#render the partner address accordingly to address_view_id
doc = etree.fromstring(arch)
for address_node in doc.xpath("//div[hasclass('o_address_format')]"):