I have been battling with this for a while. none of the two options are working neither were they giving errors. i commented the pythonic constrain method for you to see.
code snippet:
class house_development(models.Model):
    _name = 'house.development'
    _description = 'Development'
    _inherit = ["mail.thread"]
    name = fields.Char(string="Name", required=True, track_visibility='onchange')
    description = fields.Text(string="Description", track_visibility='onchange')
    # @api.one
    # @api.constrains('name')
    # def _identify_same_name(self):
    #     for record in self:
    #         if record.name in self:
    #             raise exceptions.ValidationError("There is another development/project with the same name: %s" % record.name)
    _sql_constraints = [
        ('name_unique',
         'UNIQUE(name)',
         "There is another development/project with the same name"),
    ] 
 
     
    