[FIX] base_address_city: fish crash in crm as city_id is defined only on res.partner object
This commit is contained in:
@@ -11,20 +11,21 @@ class FormatAddressMixin(models.AbstractModel):
|
||||
@api.model
|
||||
def _fields_view_get_address(self, arch):
|
||||
arch = super(FormatAddressMixin, self)._fields_view_get_address(arch)
|
||||
#render the partner address accordingly to address_view_id
|
||||
doc = etree.fromstring(arch)
|
||||
for city_node in doc.xpath("//field[@name='city']"):
|
||||
replacement_xml = """
|
||||
<div>
|
||||
<field name="country_enforce_cities" invisible="1"/>
|
||||
<field name='city' attrs="{'invisible': [('country_enforce_cities', '=', True), ('city_id', '!=', False)]}"/>
|
||||
<field name='city_id' attrs="{'invisible': [('country_enforce_cities', '=', False)]}"/>
|
||||
</div>
|
||||
"""
|
||||
city_id_node = etree.fromstring(replacement_xml)
|
||||
city_node.getparent().replace(city_node, city_id_node)
|
||||
if self._name == 'res.partner':
|
||||
#render the partner address accordingly to address_view_id
|
||||
doc = etree.fromstring(arch)
|
||||
for city_node in doc.xpath("//field[@name='city']"):
|
||||
replacement_xml = """
|
||||
<div>
|
||||
<field name="country_enforce_cities" invisible="1"/>
|
||||
<field name='city' attrs="{'invisible': [('country_enforce_cities', '=', True), ('city_id', '!=', False)]}"/>
|
||||
<field name='city_id' attrs="{'invisible': [('country_enforce_cities', '=', False)]}"/>
|
||||
</div>
|
||||
"""
|
||||
city_id_node = etree.fromstring(replacement_xml)
|
||||
city_node.getparent().replace(city_node, city_id_node)
|
||||
|
||||
arch = etree.tostring(doc)
|
||||
arch = etree.tostring(doc)
|
||||
return arch
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user