|
@ -90,28 +90,30 @@ class ResPartner(models.Model): |
|
|
if state and record.state_id != state: |
|
|
if state and record.state_id != state: |
|
|
record.state_id = record.zip_id.city_id.state_id |
|
|
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): |
|
|
def _check_zip(self): |
|
|
if self.env.context.get("skip_check_zip"): |
|
|
if self.env.context.get("skip_check_zip"): |
|
|
return |
|
|
return |
|
|
for rec in self: |
|
|
for rec in self: |
|
|
if not rec.zip_id: |
|
|
if not rec.zip_id: |
|
|
continue |
|
|
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( |
|
|
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) |
|
|
% (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( |
|
|
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) |
|
|
% (rec.name, rec.zip_id.name) |
|
|
) |
|
|
) |
|
|
if rec.zip_id.city_id != rec.city_id: |
|
|
if rec.zip_id.city_id != rec.city_id: |
|
|
raise ValidationError( |
|
|
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) |
|
|
% (rec.name, rec.zip_id.name) |
|
|
) |
|
|
) |