[FIX] base{,_address_extended}: extended fields in address format
In 6c2b54ff there was an optimization that removed extended addresses
fields syncing on parent_id, or concerning field update or creation.
But the list of fields was also used partly for formatting address which
had been supporting extended addresses fields and now does not.
With this changeset, we have the extended fields back but only for
formatting in a new "_formatting_address_fields".
opw-1984608
closes #33144
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
@@ -6,7 +6,7 @@ import re
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
STREET_FIELDS = ('street_name', 'street_number', 'street_number2')
|
||||
STREET_FIELDS = ['street_name', 'street_number', 'street_number2']
|
||||
|
||||
|
||||
class ResCountry(models.Model):
|
||||
@@ -33,6 +33,10 @@ class Partner(models.Model):
|
||||
street_number2 = fields.Char('Door', compute='_split_street', help="Door Number",
|
||||
inverse='_set_street', store=True)
|
||||
|
||||
def _formatting_address_fields(self):
|
||||
"""Returns the list of address fields usable to format addresses."""
|
||||
return super(Partner, self)._formatting_address_fields() + self.get_street_fields()
|
||||
|
||||
def get_street_fields(self):
|
||||
"""Returns the fields that can be used in a street format.
|
||||
Overwrite this function if you want to add your own fields."""
|
||||
|
||||
@@ -444,6 +444,11 @@ class Partner(models.Model):
|
||||
"""Returns the list of address fields that are synced from the parent."""
|
||||
return list(ADDRESS_FIELDS)
|
||||
|
||||
@api.model
|
||||
def _formatting_address_fields(self):
|
||||
"""Returns the list of address fields usable to format addresses."""
|
||||
return self._address_fields()
|
||||
|
||||
@api.multi
|
||||
def update_address(self, vals):
|
||||
addr_vals = {key: vals[key] for key in self._address_fields() if key in vals}
|
||||
@@ -915,7 +920,7 @@ class Partner(models.Model):
|
||||
'country_name': self._get_country_name(),
|
||||
'company_name': self.commercial_company_name or '',
|
||||
}
|
||||
for field in self._address_fields():
|
||||
for field in self._formatting_address_fields():
|
||||
args[field] = getattr(self, field) or ''
|
||||
if without_company:
|
||||
args['company_name'] = ''
|
||||
@@ -925,7 +930,7 @@ class Partner(models.Model):
|
||||
|
||||
def _display_address_depends(self):
|
||||
# field dependencies of method _display_address()
|
||||
return self._address_fields() + [
|
||||
return self._formatting_address_fields() + [
|
||||
'country_id.address_format', 'country_id.code', 'country_id.name',
|
||||
'company_name', 'state_id.code', 'state_id.name',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user