Before, if you would put Peru Street 23, it would put Peru in House number. This is because the editable field was the street field, so behind the scenes, Odoo will split it and according to the standard format without country, this means Peru will go into House. We tried first with a change inversing it, but as we are doing the change, the best thing is to remove the split all together. We added also onchange logic that if you put a district it would automatically put the right city. City or city_id should depend on the country and is correctly inherited by a fields_view_get. Task 2724531 closes odoo/odoo#85194 X-original-commit: 47cd0b51fb60cebb88e3a84b7e332e1ff800b0a8 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Josse Colpaert <jco@odoo.com>
21 lines
723 B
Python
21 lines
723 B
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details
|
|
from odoo import fields, models, api
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
l10n_pe_district = fields.Many2one(
|
|
'l10n_pe.res.city.district', string='District',
|
|
help='Districts are part of a province or city.')
|
|
|
|
@api.onchange('l10n_pe_district')
|
|
def _onchange_l10n_pe_district(self):
|
|
if self.l10n_pe_district:
|
|
self.city_id = self.l10n_pe_district.city_id
|
|
|
|
@api.onchange('city_id')
|
|
def _onchange_l10n_pe_city_id(self):
|
|
if self.city_id and self.l10n_pe_district.city_id and self.l10n_pe_district.city_id != self.city_id:
|
|
self.l10n_pe_district = False
|