|
|
@ -90,28 +90,30 @@ class ResPartner(models.Model): |
|
|
|
if state and record.state_id != state: |
|
|
|
record.state_id = record.zip_id.city_id.state_id |
|
|
|
|
|
|
|
@api.constrains("zip_id", "country_id", "city_id", "state_id") |
|
|
|
@api.constrains("zip_id", "country_id", "city_id", "state_id", "zip") |
|
|
|
def _check_zip(self): |
|
|
|
if self.env.context.get("skip_check_zip"): |
|
|
|
return |
|
|
|
for rec in self: |
|
|
|
if not rec.zip_id: |
|
|
|
continue |
|
|
|
if rec.zip_id.city_id.state_id != rec.state_id: |
|
|
|
if rec.zip_id.city_id.country_id != rec.country_id: |
|
|
|
raise ValidationError( |
|
|
|
_("The state of the partner %s differs from that in " "location %s") |
|
|
|
_("The country of the partner %s differs from that in location %s") |
|
|
|
% (rec.name, rec.zip_id.name) |
|
|
|
) |
|
|
|
if rec.zip_id.city_id.country_id != rec.country_id: |
|
|
|
if rec.zip_id.city_id.state_id != rec.state_id: |
|
|
|
raise ValidationError( |
|
|
|
_( |
|
|
|
"The country of the partner %s differs from that in " |
|
|
|
"location %s" |
|
|
|
) |
|
|
|
_("The state of the partner %s differs from that in location %s") |
|
|
|
% (rec.name, rec.zip_id.name) |
|
|
|
) |
|
|
|
if rec.zip_id.city_id != rec.city_id: |
|
|
|
raise ValidationError( |
|
|
|
_("The city of partner %s differs from that in " "location %s") |
|
|
|
_("The city of partner %s differs from that in location %s") |
|
|
|
% (rec.name, rec.zip_id.name) |
|
|
|
) |
|
|
|
if rec.zip_id.name != rec.zip: |
|
|
|
raise ValidationError( |
|
|
|
_("The zip of the partner %s differs from that in location %s") |
|
|
|
% (rec.name, rec.zip_id.name) |
|
|
|
) |