[IMP] partner_phone_country_validation:

fix partner creation with parent
This commit is contained in:
clementthomas
2024-06-20 10:01:19 +02:00
parent f6ecc778a0
commit 6c5411a2eb

View File

@@ -11,8 +11,9 @@ class Partner(models.Model):
@api.constrains('country_id','phone','mobile')
def _check_country_id(self):
if not self.country_id and (self.phone or self.mobile):
raise ValidationError(_('You must set a country for the phone number'))
for partner in self:
if not partner.country_id and not partner.parent_id.country_id and (partner.phone or partner.mobile):
raise ValidationError(_('You must set a country for the phone number of %s'%(partner.name,)))
@api.onchange('country_id')
def _onchange_country(self):