From 4373d5ff4be4c7bd608313060fe521fc83c09ce9 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 28 May 2015 11:10:17 +0200 Subject: [PATCH] Add SQL constraint on orderpoint to avoid duplicates --- stock_usability/stock.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stock_usability/stock.py b/stock_usability/stock.py index e944f3b..9542fc1 100644 --- a/stock_usability/stock.py +++ b/stock_usability/stock.py @@ -43,3 +43,14 @@ class StockPickingType(models.Model): _inherit = 'stock.picking.type' name = fields.Char(translate=False) + + +class StockWarehouseOrderpoint(models.Model): + _inherit = 'stock.warehouse.orderpoint' + + _sql_constraints = [( + 'company_wh_location_product_unique', + 'unique(company_id, warehouse_id, location_id, product_id)', + 'An orderpoint already exists for the same company, same warehouse, ' + 'same stock location and same product.' + )]