1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
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
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.
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.
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.
27
##############################################################################
29
from osv import fields,osv
34
class event_meeting_table(osv.osv):
35
_name="event.meeting.table"
36
_description="event.meeting.table"
38
'partner_id1':fields.many2one('res.partner','First Partner',required=True),
39
'partner_id2':fields.many2one('res.partner','Second Partner', required=True),
40
'event_id':fields.many2one('event.event','Related Event', required=True),
41
'contact_id1':fields.many2one('res.partner.contact','First Contact',required=True),
42
'contact_id2':fields.many2one('res.partner.contact','Second Contact', required=True),
43
'service':fields.integer('Service', required=True),
44
'table':fields.char('Table',size=10,required=True),
49
class event_check_type(osv.osv):
50
_name="event.check.type"
51
_description="event.check.type"
53
'name':fields.char('Name',size=20,required=True),
59
def cci_event_fixed(self, cr, uid, ids, *args):
60
self.write(cr, uid, ids, {'state':'fixed',})
63
def cci_event_open(self, cr, uid, ids, *args):
64
self.write(cr, uid, ids, {'state':'open',})
67
def cci_event_confirm(self, cr, uid, ids, *args):
68
self.write(cr, uid, ids, {'state':'confirm',})
71
def cci_event_running(self, cr, uid, ids, *args):
72
self.write(cr, uid, ids, {'state':'running',})
75
def cci_event_done(self, cr, uid, ids, *args):
76
self.write(cr, uid, ids, {'state':'done',})
79
def cci_event_closed(self, cr, uid, ids, *args):
80
self.write(cr, uid, ids, {'state':'closed',})
83
def cci_event_cancel(self, cr, uid, ids, *args):
84
self.write(cr, uid, ids, {'state':'cancel',})
87
def onchange_check_type(self, cr, uid, id, type):
90
tmp=self.pool.get('event.type').browse(cr, uid, type)
91
return {'value':{'check_type' : tmp.check_type.id}}
93
def _group_names(self, cr, uid, ids):
101
temp.append((r[0],r[0]))
104
_inherit="event.event"
105
_description="event.event"
107
'state': fields.selection([('draft','Draft'),('fixed','Fixed'),('open','Open'),('confirm','Confirmed'),('running','Running'),('done','Done'),('cancel','Canceled'),('closed','Closed')], 'State', readonly=True, required=True),
108
'agreement_nbr':fields.char('Agreement Nbr',size=16),
109
'note':fields.text('Note'),
110
'fse_code':fields.char('FSE code',size=64),
111
'fse_hours':fields.integer('FSE Hours'),
112
'signet_type':fields.selection(_group_names, 'Signet type'),
113
'localisation':fields.char('Localisation',size=20),
114
'account_analytic_id':fields.many2one('account.analytic.account','Analytic Account'),
115
'check_type': fields.many2one('event.check.type','Check Type'),
119
class event_check(osv.osv):
121
_description="event.check"
123
def cci_event_check_block(self, cr, uid, ids, *args):
124
self.write(cr, uid, ids, {'state':'block',})
127
def cci_event_check_confirm(self, cr, uid, ids, *args):
128
self.write(cr, uid, ids, {'state':'confirm',})
131
def cci_event_check_cancel(self, cr, uid, ids, *args):
132
self.write(cr, uid, ids, {'state':'cancel',})
136
"name": fields.char('Name', size=128, required=True),
137
"code": fields.char('Code', size=64),
138
"reg_id": fields.many2one('event.registration','Inscriptions',required=True),
139
"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')])
140
"unit_nbr": fields.float('Value'),
141
"type_id":fields.many2one('event.check.type','Type'),
142
"date_reception":fields.date("Reception Date"),
143
"date_limit":fields.date('Limit Date'),
144
"date_submission":fields.date("Submission Date"),
147
'state': lambda *args: 'draft',
148
'name': lambda *args: 'cheque',
153
class event_type(osv.osv):
154
_inherit = 'event.type'
155
_description= 'Event type'
157
'check_type': fields.many2one('event.check.type','Default Check Type'),
161
class event_group(osv.osv):
163
_description = 'event.group'
165
"name":fields.char('Group Name',size=20,required=True),
166
"bookmark_name":fields.char('Value',size=128),
167
"picture":fields.binary('Picture'),
168
"type":fields.selection([('image','Image'),('text','Text')], 'Type',required=True)
171
'type': lambda *args: 'text',
176
class event_registration(osv.osv):
178
def cci_event_reg_open(self, cr, uid, ids, *args):
179
self.write(cr, uid, ids, {'state':'open',})
180
self.pool.get('event.registration').mail_user(cr,uid,ids)
181
cases = self.browse(cr, uid, ids)
182
self.pool.get('event.registration')._history(cr, uid, cases, 'Open', history=True)
185
def cci_event_reg_done(self, cr, uid, ids, *args):
186
self.write(cr, uid, ids, {'state':'done',})
187
cases = self.browse(cr, uid, ids)
188
self.pool.get('event.registration')._history(cr, uid, cases, 'Done', history=True)
191
def cci_event_reg_cancel(self, cr, uid, ids, *args):
192
self.write(cr, uid, ids, {'state':'cancel',})
193
cases = self.browse(cr, uid, ids)
194
self.pool.get('event.registration')._history(cr, uid, cases, 'Cancel', history=True)
197
def cal_check_amount(self, cr, uid, ids, name, arg, context={}):
199
data_reg = self.browse(cr,uid,ids)
202
for check in reg.check_ids:
203
total = total + check.unit_nbr
207
_inherit = 'event.registration'
208
_description="event.registration"
210
"contact_order_id":fields.many2one('res.partner.contact','Contact Order'),
211
"group_id": fields.many2one('event.group','Event Group'),
212
"cavalier": fields.boolean('Cavalier',help="Check if we should print papers with participant name"),
213
"payment_mode":fields.many2one('payment.mode',"Payment Mode"),#should be check (m2o ?)
214
"check_mode":fields.boolean('Check Mode'),
215
"check_ids":fields.one2many('event.check','reg_id',"Check ids"),
216
"payment_ids":fields.many2many("account.move.line","move_line_registration", "reg_id", "move_line_id","Payment", readonly=True),
217
"training_authorization":fields.char('Training Auth.',size=12,help='Formation Checks Authorization number',readonly=True),
218
"check_amount":fields.function(cal_check_amount,method=True,type='float', string='Check Amount')
221
'name': lambda *a: 'Registration',
224
def write(self, cr, uid, *args, **argv):
225
if 'partner_invoice_id' in args[1] and args[1]['partner_invoice_id']:
226
data_partner = self.pool.get('res.partner').browse(cr,uid,args[1]['partner_invoice_id'])
228
args[1]['training_authorization'] = data_partner.training_authorization
229
return super(event_registration, self).write(cr, uid, *args, **argv)
231
def onchange_partner_id(self, cr, uid, ids, part, event_id, email=False):#override function for partner name.
233
data_partner = self.pool.get('res.partner').browse(cr,uid,part)
234
if data_partner.alert_events:
235
raise osv.except_osv('Error!',data_partner.alert_explanation or 'Partner is not valid')
236
return super(event_registration,self).onchange_partner_id(cr, uid, ids, part, event_id, email)
238
def onchange_partner_invoice_id(self, cr, uid, ids, event_id, partner_invoice_id):
241
data['training_authorization']=data['unit_price']=False
242
if partner_invoice_id:
243
data_partner = self.pool.get('res.partner').browse(cr,uid,partner_invoice_id)
244
data['training_authorization']=data_partner.training_authorization
246
return {'value':data}
247
data_event = self.pool.get('event.event').browse(cr,uid,event_id)
249
if data_event.product_id:
250
if not partner_invoice_id:
251
data['training_authorization']=False
252
data['unit_price']=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id],context=context)[data_event.product_id.id]
253
return {'value':data}
254
data_partner = self.pool.get('res.partner').browse(cr,uid,partner_invoice_id)
255
context.update({'partner_id':data_partner})
256
data['unit_price']=self.pool.get('product.product').price_get(cr, uid, [data_event.product_id.id],context=context)[data_event.product_id.id]
257
return {'value':data}
258
return {'value':data}
260
# def pay_and_recon(self,cr,uid,reg,inv_obj,inv_id,context={}):
264
# writeoff_account_id = False # should be check
265
# writeoff_journal_id = False # should be check
266
# data_inv = inv_obj.browse(cr,uid,inv_id)
267
# journal_obj = self.pool.get('account.journal')
268
# wf_service = netsvc.LocalService('workflow')
270
# for check in reg.check_ids:
271
# total = total + check.unit_nbr
273
# ids = self.pool.get('account.period').find(cr, uid, context=context)
278
# cash_id = journal_obj.search(cr, uid, [('type', '=', 'cash')])
279
# acc_id = journal_obj.browse(cr, uid, cash_id[0], context).default_credit_account_id.id
280
# wf_service.trg_validate(uid, 'account.invoice', inv_id, 'invoice_open', cr)
281
# 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)
287
class account_move_line(osv.osv):
288
_inherit = 'account.move.line'
290
"case_id" : fields.many2many("event.registration","move_line_registration", "move_line_id", "reg_id","Registration"),
293
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: