~openerp-commiter/openobject-addons/trunk-extra-addons

« back to all changes in this revision

Viewing changes to product_variant_configurator/product.py

  • Committer: Xavier Fernandez
  • Date: 2009-03-03 10:57:09 UTC
  • mto: (3583.1.12 addons-extra)
  • mto: This revision was merged to the branch mainline in revision 3584.
  • Revision ID: xafer@apophis-20090303105709-gz5hcqja7z4wym6w
Initial import
Work in progress

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution    
 
5
#    Copyright (C) 2009 Smile.fr. All Rights Reserved
 
6
#    authors: Raphaël Valyi, Xavier Fernandez
 
7
#
 
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.
 
12
#
 
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.
 
17
#
 
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/>.
 
20
#
 
21
##############################################################################
 
22
from osv import fields, osv
 
23
 
 
24
 
 
25
class product_product(osv.osv):
 
26
    _inherit = "product.product"
 
27
    
 
28
    # filter only the matching variants
 
29
    def name_search(self, cr, uid, name, args=None, operator='ilike', context={}, limit=80):
 
30
        
 
31
        if context and context.get('dimension_configuration_line_ids', False):
 
32
            if not args:
 
33
                args=[]
 
34
            
 
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)
 
39
 
 
40
            return self.name_get(cr, uid, ids,context)
 
41
 
 
42
        else:
 
43
            result = super(product_product, self).name_search(cr, uid, name, args, operator, context, limit)
 
44
            return result
 
45
        
 
46
        # NOTE
 
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):
 
50
 
 
51
product_product()