Browse Source

add unique constraint on pages

davidmscholz 1 day ago
parent
commit
d982913650
1 changed files with 3 additions and 0 deletions
  1. 3 0
      models/models.py

+ 3 - 0
models/models.py

@@ -16,3 +16,6 @@ class PageProductMapping(models.Model):
     # products that grant access to the page
     products = fields.Many2many('product.product', string='Alternative Products')
 
+    _sql_constraints = [
+        ('page_uniq', 'unique(page)', 'Each page can only be mapped once.'),
+    ]