1
##############################################################################
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
4
# Fabien Pinckaers <fp@tiny.Be>
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
##############################################################################
34
sms_send_form = '''<?xml version="1.0"?>
36
<separator string="%s" colspan="4"/>
37
<field name="app_id"/>
40
<field name="password"/>
42
<field name="text" colspan="3"/>
43
</form>''' % ('SMS - Gateway: clickatell', 'Bulk SMS send')
46
'app_id': {'string':'API ID', 'type':'char', 'required':True},
47
'user': {'string':'Login', 'type':'char', 'required':True},
48
'password': {'string':'Password', 'type':'char', 'required':True},
49
'text': {'string':'SMS Message', 'type':'text', 'required':True, 'value':'Les lots [lots] vous ont etes adjuges. -- Rops'}
52
def _sms_send(self, uid, datas):
53
service = netsvc.LocalService("object_proxy")
54
lots = service.execute(uid, 'auction.lots', 'read', datas['ids'], ['obj_num','obj_price','ach_uid'])
55
part = service.execute(uid, 'res.partner', 'read', [l['ach_uid'] for l in lots if l['ach_uid']], ['gsm'])
56
part = dict(map(lambda x: (x['id'],{'gsm':x['gsm'],'lots':[]}), part))
58
part[l['ach_uid']]['lots'].append(str(l['obj_num'])+'-%dEUR' % int(l['obj_price']))
60
for p in part.values():
63
params = urllib.urlencode({'user': datas['form']['user'], 'password': datas['form']['password'], 'api_id': datas['form']['app_id'], 'text':unicode(datas['form']['text'].replace('[lots]',', '.join(p['lots'])), 'utf-8').encode('latin1'), 'to':to})
64
f = urllib.urlopen("http://196.7.150.220/http/sendmsg", params)
66
return {'sms_sent':nbr}
68
class lots_sms(wizard.interface):
72
'result': {'type': 'form', 'arch':sms_send_form, 'fields': sms_send_fields, 'state':[('send','Send SMS'), ('end','Cancel')]}
75
'actions': [_sms_send],
76
'result': {'type': 'state', 'state':'end'}
79
lots_sms('auction.lots.sms_send');