1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2009 Smile.fr. All Rights Reserved
6
# authors: Raphaël Valyi, Xavier Fernandez
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
22
from osv import fields, osv
25
class product_product(osv.osv):
26
_inherit = "product.product"
28
# filter only the matching variants
29
def name_search(self, cr, uid, name, args=None, operator='ilike', context={}, limit=80):
31
if context and context.get('dimension_configuration_line_ids', False):
35
conf_lines=context.get('dimension_configuration_line_ids')
36
dim_values=[ line[2]['dimension_type_value_id'] for line in conf_lines if line[2]['modified']]
37
constraints_list=[('dimension_value_ids', 'in', [i] ) for i in dim_values]
38
ids = self.search(cr, uid, constraints_list+args,context=context)
40
return self.name_get(cr, uid, ids,context)
43
result = super(product_product, self).name_search(cr, uid, name, args, operator, context, limit)
47
# search has not been overriden on purpose for ergonomic reasons:
48
# it allows to skip the dimension filter in case of a second click on the find button
49
# def search(self, cr, uid, args=None, offset=0, limit=2000, order=None,context={}, count=False):