その時点でデータをインポートすると、本文の一部を宣言して自動的に送信される PDF レポートを添付する必要があります。手動メールを送信すると、レポートが添付されます。
class import_data(osv.osv):
_name = "import.data"
_columns = {
'csv_file' : fields.binary('CSV FILE', required="1"),
'type':fields.selection([('NSE','NSE'),('BSE','BSE'),('Unlisted','Unlisted')],'Exchange Type',required="1")
}
def send_mail_user (自己、cr、uid、ids、データ、コンテキスト = なし):
res_user_obj = self.pool.get('res.users')
user = res_user_obj.browse(cr,uid, [uid], context)[0]
mail_mail = self.pool.get('mail.mail')
this_context = context
if data.excess < 0.0:
subject = 'Share Valuation Report for' "%s" % (data.name.name) + ' | Deposite security values'
else:
subject = 'Share Valuation Report for' "%s" % (data.name.name) + ' '
if user.login:
body = '''
Dear Sir/Madam,
<p>Kindly find the share valuation report. The minimum security ratio has been maintained as on <b>''' "%s" % data.write_date +'''</b>.
<p><table>
<tr>
<td>Current Loan :
<b>''' "%s" % data.loan +'''</b>
</td>
<td>Date :
<b>''' "%s" % data.write_date +'''</b>
</td>
</tr>
<tr>
<td>Requisite Security Ratio :
<b>''' "%s" % data.rs_ratio +'''</b>
</td>
<td>Share Type :
<b>''' "%s" % data.type +'''</b>
</td>
</tr>
<tr>
<td>Requisite Security Value :
<b>''' "%s" % data.rs_value +'''</b>
</td>
<td>Excesss/(Shortfall) :
<b>''' "%s" % data.excess +'''</b>
</td>
</tr>
<tr>
<td>Total Share :
<b>''' "%s" % data.total_share +'''</b>
</td>
<td>Number of Share :
<b>''' "%s" % data.no_share +'''</b>
</td>
</tr>
</table></p>
<p>If you have any query/ clairification please contact your Relationship Manager </p>
<p>Regards, </p>
<p>''' "%s" % user.name +''' </p>
<p>''' "%s" % user.email +''' </p>
<p>''' "%s" % user.phone +''' </p>
<p>*** This is an automatically generated email, please do not reply ***</p>
'''
mail_values = {
'email_from': user.email,
'email_to': data.name.email,
'email_cc': user.email,
'subject': subject,
'body_html': body,
'state': 'outgoing',
'type': 'email',
}
mail_id = mail_mail.create(cr, uid, mail_values, context=this_context)
a=mail_mail.send(cr, uid, [mail_id], auto_commit=True, context=this_context)
return True
def import_data (自己、cr、uid、ids、コンテキスト = なし):
form = self.read(cr, uid, ids, [])
if not form[0].get('csv_file'):
raise osv.except_osv(_('Warning!'), _('Please Import CSV!'))
fdata = form and base64.decodestring(form[0]['csv_file']) or False
input = cStringIO.StringIO(fdata)
input.seek(0)
try:
data = list(csv.reader(input, quotechar='"' or '"', delimiter=','))
except:
raise osv.except_osv(_('Error!'), _('please imported CSV data file is not properly set for the delimiter !'))
mix_log=""
if data and form[0].get('type') == 'NSE':
self.create_nse(cr,uid,ids,data,context=None)
if data and form[0].get('type') == 'BSE':
self.create_bse(cr,uid,ids,data,context=None)
share_mon_obj= self.pool.get('share.monitors')
his_obj=self.pool.get('share.monitors.history')
share_mon_ids= share_mon_obj.search(cr,uid,[])
vals={}
if share_mon_ids:
for share_id in share_mon_ids:
if share_id:
c_data = share_mon_obj.browse(cr,uid,share_id)
if not c_data.share_line:
raise osv.except_osv(_('Error!'), _('please create the company and share details!'))
for c_line in c_data.share_line:
val={
'company_names' : c_line.names and c_line.names.id or False,
'isin': c_line.isin_no,
'shares' : c_line.share,
'price_quote': c_line.quote_price,
'value_gross': c_line.gross_value,
'ratio_rs': c_line.rs_ratio,
'ratio_as': c_line.as_ratio,
'write_dates' : c_line.write_date,
'monitor_ids': c_line.monitor_id and c_line.monitor_id.id or False,
'share_type':c_line.share_type or False,
}
for csv_line in data:
if form[0].get('type') == 'NSE':
if c_line.isin_no == csv_line[12] and c_line.share_type == 'NSE':
vals={
'quote_price':csv_line[5] or 0.00,
}
his_create_id=his_obj.create(cr,uid,val)
a=self.pool.get('share.monitors.info').write(cr,uid,c_line.id,vals)
if form[0].get('type') == 'BSE':
if c_line.isin_no == csv_line[0] and c_line.share_type == 'BSE':
vals={
'quote_price':csv_line[7] or 0.00,
}
his_create_id=his_obj.create(cr,uid,val)
a=self.pool.get('share.monitors.info').write(cr,uid,c_line.id,vals)
self.send_mail_user(cr, uid,ids,c_data,context=context)
return True