From 52a39e2dd2a21817bdd83e993a52d1c74a3536cb Mon Sep 17 00:00:00 2001
From: Martin Trigaux <mat@odoo.com>
Date: Mon, 19 Jan 2015 15:25:57 +0100
Subject: [PATCH] [IMP] point_of_sale: check also inactived products

use search_count instead of search
---
 addons/point_of_sale/point_of_sale.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index 130c5b0d88ce..5260111c346d 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -1427,8 +1427,9 @@ class product_template(osv.osv):
     }
 
     def unlink(self, cr, uid, ids, context=None):
-        if self.search(cr, uid, [('id', 'in', ids), ('available_in_pos', '=', True)], context=context):
-            if self.pool['pos.session'].search(cr, uid, [('state', '!=', 'closed')], context=context):
+        product_ctx = dict(context or {}, active_test=False)
+        if self.search_count(cr, uid, [('id', 'in', ids), ('available_in_pos', '=', True)], context=product_ctx):
+            if self.pool['pos.session'].search_count(cr, uid, [('state', '!=', 'closed')], context=context):
                 raise osv.except_osv(_('Error!'),
                     _('You cannot delete a product saleable in point of sale while a session is still opened.'))
         return super(product_template, self).unlink(cr, uid, ids, context=context)
-- 
GitLab