1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import fields, osv
23 from tools.translate import _
30 class auction_lots_sms_send(osv.osv_memory):
32 _name = "auction.lots.sms.send"
33 _description = "Sms send "
35 'app_id':fields.char('API ID', size=64, required=True),
36 'user':fields.char('Login', size=64, required=True),
37 'password':fields.char('Password', size=64, required=True),
38 'text':fields.text('SMS Message', required=True)
41 def sms_send(self, cr, uid, ids, context):
45 @param cr: the current row, from the database cursor.
46 @param uid: the current user’s ID for security checks.
47 @param ids: the ID or list of IDs
48 @param context: A standard dictionary
49 @return: number indicating the acknowledgement
52 lot_obj = self.pool.get('auction.lots')
53 partner_obj = self.pool.get('res.partner')
54 partner_address_obj = self.pool.get('res.partner.address')
55 for datas in self.read(cr, uid, ids):
56 lots = lot_obj.read(cr, uid, context['active_ids'], ['obj_num','obj_price','ach_uid'])
57 res = partner_obj.read(cr, uid, [l['ach_uid'][0] for l in lots if l['ach_uid']], ['gsm'], context)
61 add = partner_obj.address_get(cr, uid, [r['id']])['default']
62 addr = partner_address_obj.browse(cr, uid, add)
65 tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
67 return {'sms_sent': nbr}
70 tools.smssend(data['user'], data['password'], data['app_id'], unicode(data['text'], 'utf-8').encode('latin1'), to)
72 return {'sms_sent': nbr}
74 auction_lots_sms_send()
77 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: