[REF] Code cleaning
bzr revid: rim@openerp.com-20140106084708-7yot3pjkfbezd6f8
This commit is contained in:
@@ -37,7 +37,6 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
_log_access = True
|
||||
|
||||
def _get_public_url(self, cr, uid, ids, name, arg, context=None):
|
||||
""" Compute if the message is unread by the current user. """
|
||||
res = dict((id, 0) for id in ids)
|
||||
survey_obj = self.pool.get('survey.survey')
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
@@ -45,7 +44,7 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
return res
|
||||
|
||||
def _get_public_url_html(self, cr, uid, ids, name, arg, context=None):
|
||||
""" Compute if the message is unread by the current user. """
|
||||
""" Compute if the message is unread by the current user """
|
||||
urls = self._get_public_url(cr, uid, ids, name, arg, context=context)
|
||||
for key, url in urls.items():
|
||||
urls[key] = '<a href="%s">%s</a>' % (url, _("Click here to start survey"))
|
||||
@@ -53,9 +52,9 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
|
||||
_columns = {
|
||||
'survey_id': fields.many2one('survey.survey', 'Survey', required=True),
|
||||
'public': fields.selection([('public_link', 'Share the public web link to your audience.'), \
|
||||
('email_public_link', 'Send by email the public web link to your audience.'),\
|
||||
('email_private', 'Send private invitation to your audience (only one response per recipient and per invitation).')],
|
||||
'public': fields.selection([('public_link', 'Share the public web link to your audience.'),
|
||||
('email_public_link', 'Send by email the public web link to your audience.'),
|
||||
('email_private', 'Send private invitation to your audience (only one response per recipient and per invitation).')],
|
||||
string='Share options', required=True),
|
||||
'public_url': fields.function(_get_public_url, string="Public url", type="char"),
|
||||
'public_url_html': fields.function(_get_public_url_html, string="Public HTML web link", type="char"),
|
||||
@@ -71,7 +70,7 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
|
||||
_defaults = {
|
||||
'public': 'email_private',
|
||||
'survey_id': lambda self,cr,uid,ctx={}: ctx.get('model') == 'survey.survey' and ctx.get('res_id') or None,
|
||||
'survey_id': lambda self, cr, uid, ctx={}: ctx.get('model') == 'survey.survey' and ctx.get('res_id') or None
|
||||
}
|
||||
|
||||
def default_get(self, cr, uid, fields, context=None):
|
||||
@@ -122,7 +121,7 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
""" Process the wizard content and proceed with sending the related
|
||||
email(s), rendering any template patterns on the fly if needed. """
|
||||
email(s), rendering any template patterns on the fly if needed """
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
@@ -168,15 +167,14 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
token = uuid.uuid4().__str__()
|
||||
# create response with token
|
||||
survey_response_obj.create(cr, uid, {
|
||||
'survey_id': wizard.survey_id.id,
|
||||
'deadline': wizard.date_deadline,
|
||||
'date_create': datetime.now(),
|
||||
'type': 'link',
|
||||
'state': 'new',
|
||||
'token': token,
|
||||
'partner_id': partner_id,
|
||||
'email': email,
|
||||
})
|
||||
'survey_id': wizard.survey_id.id,
|
||||
'deadline': wizard.date_deadline,
|
||||
'date_create': datetime.now(),
|
||||
'type': 'link',
|
||||
'state': 'new',
|
||||
'token': token,
|
||||
'partner_id': partner_id,
|
||||
'email': email})
|
||||
return token
|
||||
|
||||
for wizard in self.browse(cr, uid, ids, context=context):
|
||||
@@ -220,3 +218,5 @@ class survey_mail_compose_message(osv.TransientModel):
|
||||
create_response_and_send_mail(wizard, token, partner['id'], partner['email'])
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -1,39 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!--Survey send invitation Email template -->
|
||||
<!--Survey send invitation by email: template -->
|
||||
<record id="email_template_survey" model="email.template">
|
||||
<field name="name">Survey - Send by Email</field>
|
||||
<field name="model_id" ref="model_survey_survey"/>
|
||||
<field name="auto_delete" eval="True"/>
|
||||
<field name="body_html"><![CDATA[
|
||||
<div style="font-family: 'Lucida Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); ">
|
||||
<p>Hello,</p>
|
||||
<p>We are conducting a survey, and your response would be appreciated.</p>
|
||||
<p><a href="__URL__">Please, click here to start survey</a></p>
|
||||
<p>Thanks for your participation!</p>
|
||||
</div>
|
||||
]]></field>
|
||||
<field name="model_id" ref="model_survey_survey" />
|
||||
<field name="auto_delete" eval="True" />
|
||||
<field name="body_html">
|
||||
<![CDATA[
|
||||
<div style="font-family: 'Lucida Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); ">
|
||||
<p>Hello,</p>
|
||||
<p>We are conducting a survey, and your response would be appreciated.</p>
|
||||
<p><a href="__URL__">Please, click here to start survey</a></p>
|
||||
<p>Thanks for your participation!</p>
|
||||
</div>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Replace the default mass-mailing wizard in base with the composition wizard -->
|
||||
<act_window name="Partner Survey Mailing"
|
||||
res_model="survey.mail.compose.message"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
multi="True"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="survey.action_partner_survey_mail"
|
||||
context="{
|
||||
'default_use_template': True,
|
||||
'default_template_id': ref('email_template_survey'),
|
||||
}"/>
|
||||
<!-- Replace the default mass-mailing wizard in base with the composition wizard -->
|
||||
<act_window name="Partner Survey Mailing" res_model="survey.mail.compose.message" src_model="res.partner" view_mode="form" multi="True" target="new" key2="client_action_multi" id="survey.action_partner_survey_mail" context="{'default_use_template': True, 'default_template_id': ref('email_template_survey')}" />
|
||||
|
||||
<!--Survey send
|
||||
Context['survey_resent_token'], if True, hidde share option, emails list and partner_ids
|
||||
-->
|
||||
<!-- Composition form (context['survey_resent_token'], if True, hide share option, emails list and partner_ids) -->
|
||||
<record model="ir.ui.view" id="survey_email_compose_message">
|
||||
<field name="name">survey.mail.compose.message.form</field>
|
||||
<field name="model">survey.mail.compose.message</field>
|
||||
@@ -44,33 +32,36 @@
|
||||
<field name="res_id" invisible="1"/>
|
||||
<field name="parent_id" invisible="1"/>
|
||||
<group col="2">
|
||||
<field name="survey_id" readonly="context.get('default_survey_id')" on_change="onchange_survey_id(survey_id)"/>
|
||||
<field name="public" widget="radio" invisible="context.get('survey_resent_token')"/>
|
||||
<field name="survey_id" readonly="context.get('default_survey_id')" on_change="onchange_survey_id(survey_id)" />
|
||||
<field name="public" widget="radio" invisible="context.get('survey_resent_token')" />
|
||||
</group>
|
||||
<group col="1" invisible="context.get('survey_resent_token')" attrs="{'invisible':[('public','in',['email_private', 'email_public_link'])]}" class="oe_survey_email_public">
|
||||
<div>
|
||||
<p>You can share your survey web public link and/or send private invitations to your audience. People can answer once per invitation, and whenever they want with the public web link.</p>
|
||||
<p>Copy, paste and share the web link below to your audience.</p>
|
||||
<code><field name="public_url"/></code>
|
||||
<p>Copy and paste the HTML code below to add this web link to any webpage:</p>
|
||||
<code><field name="public_url_html"/></code>
|
||||
You can share your survey web public link and/or send private invitations to your audience.<br />
|
||||
People can response once per invitation, and whenever they want with the public web link.
|
||||
</div>
|
||||
<div>Copy, paste and share the web link below to your audience.</div>
|
||||
<div>
|
||||
<field name="public_url"/>
|
||||
</div>
|
||||
<div>Copy and paste the HTML code below to add this web link to any webpage.</div>
|
||||
<div><field name="public_url_html" /></div>
|
||||
</group>
|
||||
<group col="1" attrs="{'invisible':['|',('public','=',False),('public','in',['public_link'])]}">
|
||||
<group col="2">
|
||||
<field invisible="context.get('survey_resent_token')" name="partner_ids" widget="many2many_tags_email" placeholder="Add list of existing contacts..." context="{'force_email':True, 'show_email':True}"/>
|
||||
<field invisible="context.get('survey_resent_token')" name="multi_email" placeholder="Add list of email of recipients (will not converted in partner), separated by commas, semicolons or newline..." on_change="onchange_multi_email(multi_email)" no_resize="1"/>
|
||||
<field invisible="context.get('survey_resent_token')" name="partner_ids" widget="many2many_tags_email" placeholder="Add list of existing contacts..." context="{'force_email':True, 'show_email':True}" />
|
||||
<field invisible="context.get('survey_resent_token')" name="multi_email" placeholder="Add list of email of recipients (will not converted in partner), separated by commas, semicolons or newline..." on_change="onchange_multi_email(multi_email)" no_resize="1" />
|
||||
<field name="subject" placeholder="Subject..."/>
|
||||
</group>
|
||||
<field name="body" help="__URL__ will be automatically transformed into web address (public or private, depending on your choice). You can click on 'Show Source' button to see __URL__ in the link tag on the email template."/>
|
||||
<group col="2">
|
||||
<div>
|
||||
<label for="attachment_ids"/>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
<label for="attachment_ids" />
|
||||
<field name="attachment_ids" widget="many2many_binary" />
|
||||
</div>
|
||||
<div class="oe_survey_date_deadline">
|
||||
<label for="date_deadline"/>
|
||||
<field name="date_deadline"/>
|
||||
<label for="date_deadline" />
|
||||
<field name="date_deadline" />
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
@@ -78,22 +69,19 @@
|
||||
<button string="Close" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
<footer attrs="{'invisible':['|',('public','=',False),('public','in',['public_link'])]}">
|
||||
<button string="Send" name="send_mail" type="object" class="oe_highlight"/>
|
||||
<button string="Send" name="send_mail" type="object" class="oe_highlight" />
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
<group class="oe_right" col="1">
|
||||
<div>Use template
|
||||
<field name="template_id" nolabel="1"
|
||||
on_change="onchange_template_id(template_id, composition_mode, model, res_id, context)"/>
|
||||
<div>
|
||||
Use template
|
||||
<field name="template_id" nolabel="1" on_change="onchange_template_id(template_id, composition_mode, model, res_id, context)" />
|
||||
</div>
|
||||
<button icon="/email_template/static/src/img/email_template_save.png"
|
||||
type="object" name="save_as_template" string="Save as new template" class="oe_link"
|
||||
help="Save as a new template"/>
|
||||
<button icon="/email_template/static/src/img/email_template_save.png" type="object" name="save_as_template" string="Save as new template" class="oe_link" help="Save as a new template" />
|
||||
</group>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user