Skip to content

Commit

Permalink
[Hari] | BAH-3612 | Add. sql unique constraints and index added for uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
Hari authored and rahu1ramesh committed Feb 26, 2024
1 parent 25065d4 commit c5449db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bahmni_product/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ProductProduct(models.Model):
help="Get the actual stock available for product."
"\nActual stock of product doesn't eliminates the count of expired lots from available quantities.")
mrp = fields.Float(string="MRP") # when variants exists for product, then mrp will be defined at variant level.
uuid = fields.Char(string="UUID")
uuid = fields.Char(string="UUID", index='btree_not_null')

free_qty = fields.Float(
'Free To Use Quantity ', search='_search_free_qty',
Expand All @@ -32,6 +32,10 @@ class ProductProduct(models.Model):
"Otherwise, this includes goods stored in any Stock Location "
"with 'internal' type.")

_sql_constraints = [
('unique_uuid', 'UNIQUE(uuid)', 'UUID must be unique'),
]

@api.model
def create(self, vals):
if self._context.get('create_from_tmpl'):
Expand Down

0 comments on commit c5449db

Please sign in to comment.