From f9a4ec21697681fd6fd9fe918eae35bd390dc9a9 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 25 Sep 2015 17:29:51 +0200 Subject: [PATCH] Add unique constraint (model_id, field_id) on rules --- partner_changeset/models/changeset_field_rule.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/partner_changeset/models/changeset_field_rule.py b/partner_changeset/models/changeset_field_rule.py index 31eda92e8..2da4c376c 100644 --- a/partner_changeset/models/changeset_field_rule.py +++ b/partner_changeset/models/changeset_field_rule.py @@ -43,6 +43,12 @@ class ChangesetFieldRule(models.Model): "Never: change never applied.", ) + _sql_constraints = [ + ('model_field_uniq', + 'unique (model_id, field_id)', + 'A rule already exists for this field.') + ] + @api.model def _default_model_id(self): return self.env.ref('base.model_res_partner').id