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

« back to all changes in this revision

Viewing changes to library/library.py

  • Committer: Mustufa Rangwala
  • Date: 2008-06-11 07:23:21 UTC
  • Revision ID: mra@tinyerp.com-1f024e3ce89987454b17eeada86984fede80dbad
* it defines access rules on crm object
        - some groups only can see the confidential info..
        - it defines some rules on created groups

* based on crm module

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
4
#
 
5
#
 
6
# WARNING: This program as such is intended to be used by professional
 
7
# programmers who take the whole responsability of assessing all potential
 
8
# consequences resulting from its eventual inadequacies and bugs
 
9
# End users who are looking for a ready-to-use solution with commercial
 
10
# garantees and support are strongly adviced to contract a Free Software
 
11
# Service Company
 
12
#
 
13
# This program is Free Software; you can redistribute it and/or
 
14
# modify it under the terms of the GNU General Public License
 
15
# as published by the Free Software Foundation; either version 2
 
16
# of the License, or (at your option) any later version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
26
#
 
27
##############################################################################
 
28
 
 
29
from osv import osv, fields
 
30
class library_price_category(osv.osv):
 
31
        _name = 'library.price.category'
 
32
        _description = 'Book Price Category'
 
33
        _columns = {
 
34
                'name': fields.char('Category', size=64, required=True),
 
35
                'price': fields.float('Price', required=True),
 
36
                'product_ids': fields.one2many('product.product', 'price_cat', 'Books' ,readonly=True)
 
37
        }
 
38
 
 
39
        _defaults = {
 
40
                'price': lambda *a : 0,
 
41
                }
 
42
library_price_category()
 
43
 
 
44
class library_rack(osv.osv):
 
45
        _name = 'library.rack'
 
46
        _description="Library Rack"
 
47
        _columns = {
 
48
                'name': fields.char('Name', size=64,required=True),
 
49
                'code' : fields.char('Code', size=16,),
 
50
                'active': fields.boolean('Active'),
 
51
                }
 
52
 
 
53
        _defaults= {
 
54
                'active': lambda *a: True
 
55
                }
 
56
library_rack()
 
57
 
 
58
class library_collection(osv.osv):
 
59
        _name = 'library.collection'
 
60
        _description="Library Collection"
 
61
        _columns = {
 
62
                'name': fields.char('Name', size=64,required=True),
 
63
                'code' : fields.char('Code', size=16,),
 
64
                }
 
65
library_collection()
 
66
 
 
67
class library_author(osv.osv):
 
68
        _name = 'library.author'
 
69
        _description="Author"
 
70
        _columns = {
 
71
                'name': fields.char('Name', size=64,required=True, select=True),
 
72
                'first_name':fields.char('First Name', size=64),
 
73
                'born_date': fields.date('Date of birth'),
 
74
                'death_date': fields.date('Date of death'),
 
75
                'biography': fields.text('Biography'),
 
76
                'note': fields.text('Notes'),
 
77
                'editor_ids': fields.many2many('res.partner','author_editor_rel','author_id','partner_id','Editors', select=1), 
 
78
        }
 
79
        def name_get(self, cr, uid, ids, context={}):
 
80
                if not len(ids):
 
81
                        return []
 
82
                reads = self.read(cr, uid, ids, ['name','first_name'], context)
 
83
                return map(lambda x: (x['id'], x['name'] + (x['first_name'] and (', '+x['first_name']) or '')), reads)
 
84
library_author()