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

« back to all changes in this revision

Viewing changes to product_links/product_links.py

  • Committer: Albert Cervera i Areny
  • Date: 2011-06-14 09:51:35 UTC
  • mfrom: (5345.1.165 openobject-addons)
  • Revision ID: albert@nan-tic.com-20110614095135-1x3p6tmil5lxkl9b
Merge and add nan_remove_default_filters

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Author Guewen Baconnier. Copyright Camptocamp SA
 
5
#
 
6
#    This program is free software: you can redistribute it and/or modify
 
7
#    it under the terms of the GNU General Public License as published by
 
8
#    the Free Software Foundation, either version 3 of the License, or
 
9
#    (at your option) any later version.
 
10
#
 
11
#    This program is distributed in the hope that it will be useful,
 
12
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
#    GNU General Public License for more details.
 
15
#
 
16
#    You should have received a copy of the GNU General Public License
 
17
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
##############################################################################
 
20
 
 
21
from osv import fields, osv
 
22
from base_external_referentials import external_osv
 
23
 
 
24
class product_link(external_osv.external_osv):
 
25
    _name = 'product.link'
 
26
    _rec_name = 'linked_product_id'
 
27
 
 
28
    def get_link_type_selection(self, cr, uid, context=None):
 
29
        # selection can be inherited
 
30
        return [('cross_sell', 'Cross-Sell'), ('up_sell', 'Up-Sell'), ('related', 'Related')]
 
31
 
 
32
    _columns = {
 
33
        'product_id': fields.many2one('product.product', 'Source product', required=True),
 
34
        'linked_product_id': fields.many2one('product.product', 'Linked product', required=True),
 
35
        'type': fields.selection(get_link_type_selection, 'Link type', required=True)
 
36
    }
 
37
 
 
38
product_link()
 
39
 
 
40
class product(osv.osv):
 
41
    """Inherit product in order to manage product links"""
 
42
    _inherit = 'product.product'
 
43
 
 
44
    _columns = {
 
45
        'product_link_ids': fields.one2many(
 
46
            'product.link',
 
47
            'product_id',
 
48
            'Product links',
 
49
            required=False,
 
50
            ),
 
51
        }
 
52
 
 
53
product()