1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
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
##############################################################################
23
from osv import fields,osv
28
class event_meeting_table(osv.osv):
29
_name="event.meeting.table"
30
_description="event.meeting.table"
32
'partner_id1':fields.many2one('res.partner','First Partner',required=True),
33
'partner_id2':fields.many2one('res.partner','Second Partner', required=True),
34
'event_id':fields.many2one('event.event','Related Event', required=True),
35
'contact_id1':fields.many2one('res.partner.contact','First Contact',required=True),
36
'contact_id2':fields.many2one('res.partner.contact','Second Contact', required=True),
37
'service':fields.integer('Service', required=True),
38
'table':fields.char('Table',size=10,required=True),
43
class event_check_type(osv.osv):
44
_name="event.check.type"
45
_description="event.check.type"
47
'name':fields.char('Name',size=20,required=True),
53
def cci_event_fixed(self, cr, uid, ids, *args):
54
self.write(cr, uid, ids, {'state':'fixed',})
57
def cci_event_open(self, cr, uid, ids, *args):
58
self.write(cr, uid, ids, {'state':'open',})
61
def cci_event_confirm(self, cr, uid, ids, *args):
62
self.write(cr, uid, ids, {'state':'confirm',})
65
def cci_event_running(self, cr, uid, ids, *args):
66
self.write(cr, uid, ids, {'state':'running',})
69
def cci_event_done(self, cr, uid, ids, *args):
70
self.write(cr, uid, ids, {'state':'done',})
73
def cci_event_closed(self, cr, uid, ids, *args):
74
self.write(cr, uid, ids, {'state':'closed',})
77
def cci_event_cancel(self, cr, uid, ids, *args):
78
self.write(cr, uid, ids, {'state':'cancel',})
81
def onchange_check_type(self, cr, uid, id, type):
84
tmp=self.pool.get('event.type').browse(cr, uid, type)
85
return {'value':{'check_type' : tmp.check_type.id}}
87
def _group_names(self, cr, uid, ids):
95
temp.append((r[0],r[0]))
98
_inherit="event.event"
99
_description="event.event"
101
'state': fields.selection([('draft','Draft'),('fixed','Fixed'),('open','Open'),('confirm','Confirmed'),('running','Running'),('done','Done'),('cancel','Canceled'),('closed','Closed')], 'State', readonly=True, required=True),
102
'agreement_nbr':fields.char('Agreement Nbr',size=16),
103
'note':fields.text('Note'),
104
'fse_code':fields.char('FSE code',size=64),
105
'fse_hours':fields.integer('FSE Hours'),
106
'signet_type':fields.selection(_group_names, 'Signet type'),
107
'localisation':fields.char('Localisation',size=20),
108
'account_analytic_id':fields.many2one('account.analytic.account','Analytic Account'),
109
'check_type': fields.many2one('event.check.type','Check Type'),
113
class event_check(osv.osv):
115
_description="event.check"
117
def cci_event_check_block(self, cr, uid, ids, *args):
118
self.write(cr, uid, ids, {'state':'block',})
121
def cci_event_check_confirm(self, cr, uid, ids, *args):
122
self.write(cr, uid, ids, {'state':'confirm',})
125
def cci_event_check_cancel(self, cr, uid, ids, *args):
126
self.write(cr, uid, ids, {'state':'cancel',})
130
"name": fields.char('Name', size=128, required=True),
131
"code": fields.char('Code', size=64),
132
"reg_id": fields.many2one('event.registration','Inscriptions',required=True),
133
"state": fields.selection([('draft','Draft'),('block','Blocked'),('confirm','Confirm'),('cancel','Cancel'),('asked','Asked')], 'State', readonly=True),#should be check (previous states :('open','Open'),('block','Blocked'),('paid','Paid'),('refused','Refused'),('asked','Asked')])
134
"unit_nbr": fields.float('Value'),
135
"type_id":fields.many2one('event.check.type','Type'),
136
"date_reception":fields.date("Reception Date"),
137
"date_limit":fields.date('Limit Date'),
138
"date_submission":fields.date("Submission Date"),
141
'state': lambda *args: 'draft',
142
'name': lambda *args: 'cheque',
147
class event_type(osv.osv):
148
_inherit = 'event.type'
149
_description= 'Event type'
151
'check_type': fields.many2one('event.check.type','Default Check Type'),
155
class event_group(osv.osv):
157
_description = 'event.group'
159
"name":fields.char('Group Name',size=20,required=True),
160
"bookmark_name":fields.char('Value',size=128),
161
"picture":fields.binary('Picture'),
162
"type":fields.selection([('image','Image'),('text','Text')], 'Type',required=True)
165
'type': lambda *args: 'text',
170
class event_registration(osv.osv):
172
def cci_event_reg_open(self, cr, uid, ids, *args):
173
self.write(cr, uid, ids, {'state':'open',})
174
self.pool.get('event.registration').mail_user(cr,uid,ids)
175
self.pool.get('event.registration')._history(cr, uid, ids, 'Open', history=True)
178
def cci_event_reg_done(self, cr, uid, ids, *args):
179
self.write(cr, uid, ids, {'state':'done',})
180
self.pool.get('event.registration')._history(cr, uid, ids, 'Done', history=True)
183
def cci_event_reg_cancel(self, cr, uid, ids, *args):
184
self.write(cr, uid, ids, {'state':'cancel',})
185
self.pool.get('event.registration')._history(cr, uid, ids, 'Cancel', history=True)
188
def cal_check_amount(self, cr, uid, ids, name, arg, context={}):
190
data_reg = self.browse(cr,uid,ids)
193
for check in reg.check_ids:
194
total = total + check.unit_nbr
198
_inherit = 'event.registration'
199
_description="event.registration"
201
"contact_order_id":fields.many2one('res.partner.contact','Contact Order'),
202
"group_id": fields.many2one('event.group','Event Group'),
203
"cavalier": fields.boolean('Cavalier',help="Check if we should print papers with participant name"),
204
"payment_mode":fields.many2one('payment.mode',"Payment Mode"),#should be check (m2o ?)
205
"check_mode":fields.boolean('Check Mode'),
206
"check_ids":fields.one2many('event.check','reg_id',"Check ids"),
207
"payment_ids":fields.many2many("account.move.line","move_line_registration", "reg_id", "move_line_id","Payment", readonly=True),
208
"training_authorization":fields.char('Training Auth.',size=12,help='Formation Checks Authorization number',readonly=True),
209
"check_amount":fields.function(cal_check_amount,method=True,type='float', string='Check Amount')
212
'name': lambda *a: 'Registration',
215
def write(self, cr, uid, *args, **argv):
216
if 'partner_invoice_id' in args[1] and args[1]['partner_invoice_id']:
217
data_partner = self.pool.get('res.partner').browse(cr,uid,args[1]['partner_invoice_id'])
219
args[1]['training_authorization'] = data_partner.training_authorization
220
return super(event_registration, self).write(cr, uid, *args, **argv)
222
def onchange_partner_id(self, cr, uid, ids, part, event_id, email=False):#override function for partner name.
224
data_partner = self.pool.get('res.partner').browse(cr,uid,part)
225
if data_partner.alert_events:
226
raise osv.except_osv('Error!',data_partner.alert_explanation or 'Partner is not valid')
227
return super(event_registration,self).onchange_partner_id(cr, uid, ids, part, event_id, email)
229
def onchange_partner_invoice_id(self, cr, uid, ids, event_id, partner_invoice_id):
232
data['training_authorization']=data['unit_price']=False
233
if partner_invoice_id:
234
data_partner = self.pool.get('res.partner').browse(cr,uid,partner_invoice_id)
235
data['training_authorization']=data_partner.training_authorization
237
return {'value':data}
238
data_event = self.pool.get('event.event').browse(cr,uid,event_id)
240
if data_event.product_id:
241
if not partner_invoice_id:
242
data['training_authorization']=False
243
data['unit_price']=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id],context=context)[data_event.product_id.id]
244
return {'value':data}
245
data_partner = self.pool.get('res.partner').browse(cr,uid,partner_invoice_id)
246
context.update({'partner_id':data_partner})
247
data['unit_price']=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id],context=context)[data_event.product_id.id]
248
return {'value':data}
249
return {'value':data}
251
# def pay_and_recon(self,cr,uid,reg,inv_obj,inv_id,context={}):
255
# writeoff_account_id = False # should be check
256
# writeoff_journal_id = False # should be check
257
# data_inv = inv_obj.browse(cr,uid,inv_id)
258
# journal_obj = self.pool.get('account.journal')
259
# wf_service = netsvc.LocalService('workflow')
261
# for check in reg.check_ids:
262
# total = total + check.unit_nbr
264
# ids = self.pool.get('account.period').find(cr, uid, context=context)
269
# cash_id = journal_obj.search(cr, uid, [('type', '=', 'cash')])
270
# acc_id = journal_obj.browse(cr, uid, cash_id[0], context).default_credit_account_id.id
271
# wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
272
# inv_obj.pay_and_reconcile(cr,uid,[inv_id],total, acc_id, period_id, cash_id[0], writeoff_account_id, period_id, writeoff_journal_id, context)
278
class account_move_line(osv.osv):
279
_inherit = 'account.move.line'
281
"case_id" : fields.many2many("event.registration","move_line_registration", "move_line_id", "reg_id","Registration"),
284
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: