[MERGE] merge with trunk addons
bzr revid: mra@mra-laptop-20100624112346-g95lwa5h0bnkgzgx
This commit is contained in:
@@ -108,7 +108,8 @@ class email_template(osv.osv):
|
||||
'enforce_from_account':fields.many2one(
|
||||
'email_template.account',
|
||||
string="Enforce From Account",
|
||||
help="Emails will be sent only from this account."),
|
||||
help="Emails will be sent only from this account(which are approved).",
|
||||
domain=[('state','=','approved')]),
|
||||
'from_email' : fields.related('enforce_from_account', 'email_id',
|
||||
type='char', string='From',),
|
||||
'def_to':fields.char(
|
||||
@@ -580,8 +581,8 @@ class email_template(osv.osv):
|
||||
context)
|
||||
|
||||
print 'Sending', mailbox_id
|
||||
self.pool.get('email_template.mailbox').send_this_mail(cursor, user, [mailbox_id], context)
|
||||
return mailbox_id
|
||||
|
||||
|
||||
def generate_mail(self,
|
||||
cursor,
|
||||
@@ -595,6 +596,7 @@ class email_template(osv.osv):
|
||||
if not template:
|
||||
raise Exception("The requested template could not be loaded")
|
||||
print 'loaded', record_ids
|
||||
result = True
|
||||
for record_id in record_ids:
|
||||
mailbox_id = self._generate_mailbox_item_from_template(
|
||||
cursor,
|
||||
@@ -625,7 +627,9 @@ class email_template(osv.osv):
|
||||
{'folder':'outbox'},
|
||||
context=context
|
||||
)
|
||||
return True
|
||||
# TODO : manage return value of all the records
|
||||
result = self.pool.get('email_template.mailbox').send_this_mail(cursor, user, [mailbox_id], context)
|
||||
return result
|
||||
|
||||
email_template()
|
||||
|
||||
@@ -641,7 +645,7 @@ class email_template_preview(osv.osv_memory):
|
||||
if 'template_id' in context.keys():
|
||||
ref_obj_id = self.pool.get('email.template').read(cr, uid, context['template_id'], ['object_name'], context)
|
||||
ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model']
|
||||
ref_obj_ids = self.pool.get(ref_obj_name).search(cr, uid, [], context=context)
|
||||
ref_obj_ids = self.pool.get(ref_obj_name).search(cr, uid, [], 0, 20, 'id desc', context=context)
|
||||
ref_obj_recs = self.pool.get(ref_obj_name).name_get(cr, uid, ref_obj_ids, context)
|
||||
return ref_obj_recs
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ class email_template_account(osv.osv):
|
||||
return result
|
||||
|
||||
def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, context=None):
|
||||
#TODO: Replace all this crap with a single email object
|
||||
#TODO: Replace all this with a single email object
|
||||
if body is None:
|
||||
body = {}
|
||||
if payload is None:
|
||||
@@ -320,19 +320,20 @@ class email_template_account(osv.osv):
|
||||
msg.attach(part)
|
||||
except Exception, error:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:MIME Error\nDescription: %s") % (id, error))
|
||||
return error
|
||||
return {'error_msg': "Server Send Error\nDescription: %s"%error}
|
||||
try:
|
||||
#print msg['From'],toadds
|
||||
serv.sendmail(msg['From'], addresses_l['all'], msg.as_string())
|
||||
except Exception, error:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Server Send Error\nDescription: %s") % (id, error))
|
||||
return error
|
||||
return {'error_msg': "Server Send Error\nDescription: %s"%error}
|
||||
#The mail sending is complete
|
||||
serv.close()
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_INFO, _("Mail from Account %s successfully Sent.") % (id))
|
||||
return True
|
||||
else:
|
||||
logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
|
||||
return {'error_msg':"Mail from Account %s failed. Probable Reason:Account not approved"% id}
|
||||
|
||||
def extracttime(self, time_as_string):
|
||||
"""
|
||||
@@ -394,7 +395,6 @@ class email_template_account(osv.osv):
|
||||
return date_as_date
|
||||
|
||||
def send_receive(self, cr, uid, ids, context=None):
|
||||
self.get_mails(cr, uid, ids, context)
|
||||
for id in ids:
|
||||
ctx = context.copy()
|
||||
ctx['filters'] = [('account_id', '=', id)]
|
||||
|
||||
@@ -56,18 +56,19 @@ class email_template_mailbox(osv.osv):
|
||||
values['subject'] or u'',
|
||||
{'text':values.get('body_text', u'') or u'', 'html':values.get('body_html', u'') or u''},
|
||||
payload=payload, context=context)
|
||||
|
||||
if result == True:
|
||||
self.write(cr, uid, id, {'folder':'sent', 'state':'na', 'date_mail':time.strftime("%Y-%m-%d %H:%M:%S")}, context)
|
||||
self.historise(cr, uid, [id], "Email sent successfully", context)
|
||||
else:
|
||||
self.historise(cr, uid, [id], result, context)
|
||||
error = result['error_msg']
|
||||
self.historise(cr, uid, [id], error, context)
|
||||
|
||||
except Exception, error:
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel(_("Power Email"), netsvc.LOG_ERROR, _("Sending of Mail %s failed. Probable Reason:Could not login to server\nError: %s") % (id, error))
|
||||
self.historise(cr, uid, [id], error, context)
|
||||
self.write(cr, uid, id, {'state':'na'}, context)
|
||||
return True
|
||||
return result
|
||||
|
||||
def historise(self, cr, uid, ids, message='', context=None):
|
||||
for id in ids:
|
||||
|
||||
@@ -8,33 +8,29 @@
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email Preview">
|
||||
<field name="rel_model" />
|
||||
<newline />
|
||||
<field name="rel_model_ref" on_change="on_change_ref(rel_model_ref, context)" />
|
||||
<newline />
|
||||
<field name="to" />
|
||||
<newline />
|
||||
<field name="cc" />
|
||||
<newline />
|
||||
<field name="bcc" />
|
||||
<newline />
|
||||
<field name="subject" />
|
||||
<newline />
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_text" nolabel="1" colspan="2"/>
|
||||
<newline/>
|
||||
<separator string= "Body(Html)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_html" nolabel="1" colspan="2"/>
|
||||
<newline />
|
||||
<field name="report" />
|
||||
<newline/>
|
||||
<button icon="gtk-ok" special="cancel" string="OK" colspan="2"/>
|
||||
<group col="4" colspan="4">
|
||||
<field name="rel_model" />
|
||||
<field name="rel_model_ref" on_change="on_change_ref(rel_model_ref, context)"/>
|
||||
</group>
|
||||
<group col="8" colspan="4">
|
||||
<field name="to" />
|
||||
<field name="cc" />
|
||||
<field name="bcc" />
|
||||
<field name="subject" />
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<separator string= "Body(Text)" colspan="2"/>
|
||||
<separator string= "Body(Html)" colspan="2"/>
|
||||
<newline/>
|
||||
<field name="body_text" nolabel="1" colspan="2"/>
|
||||
<field name="body_html" nolabel="1" colspan="2"/>
|
||||
</group>
|
||||
<field name="report" colspan="2"/>
|
||||
<button icon="gtk-ok" special="cancel" string="OK" colspan="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="wizard_email_template_preview" model="ir.actions.act_window">
|
||||
<field name="name">Template Preview</field>
|
||||
<field name="res_model">email_template.preview</field>
|
||||
|
||||
@@ -106,6 +106,9 @@ class l10n_be_vat_declaration(osv.osv_memory):
|
||||
data_of_file +='\n\t\t<DATA>\n\t\t\t<DATA_ELEM>'
|
||||
|
||||
for item in tax_info:
|
||||
if item['code'] == '91' and ending_month != 12:
|
||||
#the tax code 91 can only be send for the declaration of December
|
||||
continue
|
||||
if item['code']:
|
||||
if item['code'] == '71-72':
|
||||
item['code']='71'
|
||||
|
||||
@@ -73,11 +73,19 @@ you required for the campaign"),
|
||||
campaign = self.browse(cr, uid, ids[0])
|
||||
if not campaign.activity_ids :
|
||||
raise osv.except_osv("Error", "There is no activitity in the campaign")
|
||||
act_ids = [ act_id.id for act_id in campaign.activity_ids]
|
||||
act_ids = self.pool.get('marketing.campaign.activity').search(cr, uid,
|
||||
[('id', 'in', act_ids), ('start', '=', True)])
|
||||
actvity_ids = [ act_id.id for act_id in campaign.activity_ids]
|
||||
act_obj = self.pool.get('marketing.campaign.activity')
|
||||
act_ids = act_obj.search(cr, uid, [('id', 'in', actvity_ids),
|
||||
('start', '=', True)])
|
||||
if not act_ids :
|
||||
raise osv.except_osv("Error", "There is no starting activitity in the campaign")
|
||||
act_ids = act_obj.search(cr, uid, [('id', 'in', actvity_idsf),
|
||||
('type', '=', 'email')])
|
||||
for activity in act_obj.browse(cr, uid, act_ids):
|
||||
if not activity.email_template_id.enforce_from_account :
|
||||
raise osv.except_osv("Error", "Campaign cannot be start : Email Account is missing in email activity")
|
||||
if activity.email_template_id.enforce_from_account.state != 'approved' :
|
||||
raise osv.except_osv("Error", "Campaign cannot be start : Email Account is not approved for email activity")
|
||||
self.write(cr, uid, ids, {'state': 'running'})
|
||||
return True
|
||||
|
||||
@@ -239,7 +247,7 @@ class marketing_campaign_activity(osv.osv):
|
||||
def __init__(self, *args):
|
||||
self._actions = {'paper' : self.process_wi_report,
|
||||
'email' : self.process_wi_email,
|
||||
'server_action' : self.process_wi_action,
|
||||
'action' : self.process_wi_action,
|
||||
}
|
||||
return super(marketing_campaign_activity, self).__init__(*args)
|
||||
|
||||
@@ -273,13 +281,15 @@ class marketing_campaign_activity(osv.osv):
|
||||
return True
|
||||
|
||||
def process_wi_email(self, cr, uid, activity, workitem, context=None):
|
||||
return self.pool.get('email.template').generate_mail(cr, uid, activity.email_template_id.id, [workitem.res_id], context=context)
|
||||
return self.pool.get('email.template').generate_mail(cr, uid,
|
||||
activity.email_template_id.id,
|
||||
[workitem.res_id], context=context)
|
||||
|
||||
def process_wi_action(self, cr, uid, activity, workitem, context={}):
|
||||
context = {}
|
||||
server_obj = self.pool.get('ir.actions.server')
|
||||
server_obj.run(cr, uid, [activity.server_action_id.id], context)
|
||||
return True
|
||||
context['active_id'] = workitem.res_id
|
||||
return server_obj.run(cr, uid, [activity.server_action_id.id], context)
|
||||
|
||||
def process(self, cr, uid, act_id, wi_id, context={}):
|
||||
activity = self.browse(cr, uid, act_id)
|
||||
@@ -339,7 +349,7 @@ class marketing_campaign_workitem(osv.osv):
|
||||
type='many2one', relation='marketing.campaign', string='Campaign', readonly=True),
|
||||
'object_id': fields.related('segment_id', 'campaign_id', 'object_id',
|
||||
type='many2one', relation='ir.model', string='Object', select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1, readonly=1),
|
||||
'res_name': fields.function(_res_name_get, method=True, string='Resource Name', type="char", size=64),
|
||||
'date': fields.datetime('Execution Date'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', select=1),
|
||||
@@ -408,7 +418,7 @@ class marketing_campaign_workitem(osv.osv):
|
||||
else:
|
||||
vals = {'state': 'exception'}
|
||||
if type(result) == type({}) and 'error_msg' in result:
|
||||
vals['error_msg'] = result['error_msg']
|
||||
vals['error_msg'] = result['error_msg']
|
||||
self.write(cr, uid, wi.id, vals)
|
||||
else:
|
||||
self.write(cr, uid, wi.id, {'state': 'cancelled'})
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
<field name="name" select="1" />
|
||||
<field name="start"/>
|
||||
<field name="variable_cost" select="1"/>
|
||||
<field name="object_id" invisible="1"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Condition" colspan="2"/>
|
||||
@@ -44,7 +45,7 @@
|
||||
<field name="report_directory_id" attrs="{'required':[('type','=','paper')]}" />
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('type','!=','action')]}" >
|
||||
<field name="server_action_id" attrs="{'required':[('type','=','action')]}" />
|
||||
<field name="server_action_id" attrs="{'required':[('type','=','action')]}" domain="[('model_id','=',object_id)]" />
|
||||
</group>
|
||||
<group colspan="4" attrs="{'invisible':[('type','!=','subcampaign')]}" >
|
||||
<field name="subcampaign_id" attrs="{'required':[('type','=','subcampaign')]}" />
|
||||
@@ -366,6 +367,7 @@
|
||||
<field name="partner_id"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
<button string="Preview" states="todo" name="preview" icon="gtk-apply" type="object"/>
|
||||
<button string="Process" states="todo" name="process" type="object" icon="gtk-ok"/>
|
||||
<button string="Cancel" states="todo" name="button_cancel" type="object" icon="gtk-cancel"/>
|
||||
</tree>
|
||||
|
||||
Reference in New Issue
Block a user