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

« back to all changes in this revision

Viewing changes to sale_advertising/sale_advertising.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
#
 
4
# Copyright (c) 2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
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 fields,osv
 
30
from osv import orm
 
31
import time
 
32
 
 
33
 
 
34
 
 
35
class sale_order(osv.osv):
 
36
        _inherit = "sale.order"
 
37
 
 
38
        _columns = {
 
39
                'published_customer': fields.many2one('res.partner','Published Customer'),
 
40
                'advertising_agency': fields.many2one('res.partner','Advertising Agency'),
 
41
        }
 
42
 
 
43
        def onchange_published_customer(self, cursor, user, ids ,published_customer):
 
44
                data = {'advertising_agency':published_customer,'partner_id':published_customer,'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False}
 
45
                if published_customer:
 
46
                        address = self.onchange_partner_id(cursor, user, ids, published_customer)
 
47
                        data.update(address['value'])
 
48
                return {'value' : data}
 
49
 
 
50
        def onchange_advertising_agency(self, cursor, user, ids, ad_agency):
 
51
                data = {'partner_id':ad_agency,'partner_invoice_id': False, 'partner_shipping_id':False, 'partner_order_id':False}
 
52
                if ad_agency:
 
53
                        address = self.onchange_partner_id(cursor, user, ids, ad_agency)
 
54
                        data.update(address['value'])
 
55
                return {'value' : data}
 
56
 
 
57
sale_order()
 
58
 
 
59
class sale_advertising_issue(osv.osv):
 
60
        _name = "sale.advertising.issue"
 
61
        _description="Sale Advertising Issue"
 
62
        _columns = {
 
63
                'name': fields.char('Name', size=32, required=True),
 
64
                'issue_date': fields.date('Issue Date', required=True),
 
65
                'medium': fields.many2one('product.category','Medium', required=True),
 
66
                'state': fields.selection([('open','Open'),('close','Close')], 'State'),
 
67
                'default_note': fields.text('Default Note'),
 
68
        }
 
69
        _defaults = {
 
70
                'issue_date': lambda *a: time.strftime('%Y-%m-%d'),
 
71
                'state': lambda *a: 'open',
 
72
        }
 
73
 
 
74
sale_advertising_issue()
 
75
 
 
76
class sale_order_line(osv.osv):
 
77
        _inherit = "sale.order.line"
 
78
        _columns = {
 
79
                'layout_remark': fields.text('Layout Remark'),
 
80
                'adv_issue': fields.many2one('sale.advertising.issue','Advertising Issue'),
 
81
                'page_reference': fields.char('Reference of the Page', size=32),
 
82
                'from_date': fields.datetime('Start of Validity'),
 
83
                'to_date': fields.datetime('End of Validity'),
 
84
        }
 
85
sale_order_line()
 
86
 
 
87
class product_product(osv.osv):
 
88
        _inherit = "product.product"
 
89
        _columns = {
 
90
                'equivalency_in_A4': fields.float('A4 Equivalency'),
 
91
        }
 
92
product_product()
 
93
 
 
94
class sale_advertising_proof(osv.osv):
 
95
        _name = "sale.advertising.proof"
 
96
        _description="Sale Advertising Proof"
 
97
        _columns = {
 
98
                'name': fields.char('Name', size=32, required=True),
 
99
                'address_id':fields.many2one('res.partner.address','Delivery Address', required=True),
 
100
                'number': fields.integer('Number of Copies', required=True),
 
101
                'target_id': fields.many2one('sale.order','Target', required=True),
 
102
        }
 
103
        _defaults = {
 
104
                'number': lambda *a: 1,
 
105
        }
 
106
sale_advertising_proof()
 
107
 
 
108