<field name="name">Badge Form</field>
<field name="model">gamification.badge</field>
<field name="arch" type="xml">
- <form string="Badge" version="7.0">
+ <form string="Badge">
<header>
<button string="Grant this Badge" type="action" name="%(action_grant_wizard)d" class="oe_highlight" attrs="{'invisible': [('remaining_sending','=',0)]}" />
- <button string="Check Badge" type="object" name="check_automatic" groups="base.group_no_one" />
</header>
<sheet>
<div class="oe_right oe_button_box">
if diff > 0:
leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context)
elif diff < 0:
- leave_id = holiday_obj.create(cr, uid, {'name': _('Leave Request for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': abs(diff)}, context=context)
+ raise osv.except_osv(_('Warning!'), _('You cannot reduce validated allocation requests'))
else:
return False
- holiday_obj.signal_confirm(cr, uid, [leave_id])
- holiday_obj.signal_validate(cr, uid, [leave_id])
- holiday_obj.signal_second_validate(cr, uid, [leave_id])
+ for sig in ('confirm', 'validate', 'second_validate'):
+ holiday_obj.signal_workflow(cr, uid, [leave_id], sig)
return True
def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
'delay_endings_days': fields.float('Overpassed Deadline', digits=(16,2), readonly=True),
'nbr': fields.integer('# of tasks', readonly=True),
'priority': fields.selection([('0','Low'), ('1','Normal'), ('2','High')],
- string='Priority', readonly=True),
+ string='Priority', size=1, readonly=True),
- 'state': fields.selection([('draft', 'Draft'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')],'Status', readonly=True),
'company_id': fields.many2one('res.company', 'Company', readonly=True),
'partner_id': fields.many2one('res.partner', 'Contact', readonly=True),
'stage_id': fields.many2one('project.task.type', 'Stage'),
'filter_display_data': filter_display_data,
'filter_finish': filter_finish
})
+ # Quick retroengineering of what is injected into the template for now:
+ # (TODO: flatten and simplify this)
+ #
+ # survey: a browse record of the survey
+ # survey_dict: very messy dict containing all the info to display answers
+ # {'page_ids': [
+ #
+ # ...
+ #
+ # {'page': browse record of the page,
+ # 'question_ids': [
+ #
+ # ...
+ #
+ # {'graph_data': data to be displayed on the graph
+ # 'input_summary': number of answered, skipped...
+ # 'prepare_result': {
+ # answers displayed in the tables
+ # }
+ # 'question': browse record of the question_ids
+ # }
+ #
+ # ...
+ #
+ # ]
+ # }
+ #
+ # ...
+ #
+ # ]
+ # }
+ #
+ # page_range: pager helper function
+ # current_filters: a list of ids
+ # filter_display_data: [{'labels': ['a', 'b'], question_text} ... ]
+ # filter_finish: boolean => only finished surveys or not
+ #
- def prepare_result_dict(self,survey, current_filters=[]):
+ def prepare_result_dict(self,survey, current_filters=None):
"""Returns dictionary having values for rendering template"""
+ current_filters = current_filters if current_filters else []
survey_obj = request.registry['survey.survey']
- result = {'survey':survey, 'page_ids': []}
+ result = {'page_ids': []}
for page in survey.page_ids:
page_dict = {'page': page, 'question_ids': []}
for question in page.question_ids:
filter_display_data.append({'question_text': question.question, 'labels': [label.value for label in labels]})
return filter_display_data
- def prepare_result(self, cr, uid, question, current_filters=[], context=None):
+ def prepare_result(self, cr, uid, question, current_filters=None, context=None):
''' Compute statistical data for questions by counting number of vote per choice on basis of filter '''
- if context is None:
- context = {}
+ current_filters = current_filters if current_filters else []
+ context = context if context else {}
+
#Calculate and return statistics for choice
if question.type in ['simple_choice', 'multiple_choice']:
- answers = {}
- comments = []
- [answers.update({label.id: {'text': label.value, 'count': 0, 'answer_id': label.id}}) for label in question.labels_ids]
- for input_line in question.user_input_line_ids:
- if input_line.answer_type == 'suggestion' and answers.get(input_line.value_suggested.id) and (not(current_filters) or input_line.user_input_id.id in current_filters):
- answers[input_line.value_suggested.id]['count'] += 1
- if input_line.answer_type == 'text' and (not(current_filters) or input_line.user_input_id.id in current_filters):
- comments.append(input_line)
+ result_summary = []
+ for label in question.labels_ids:
+ count = 0
++ comments = []
+ for input_line in question.user_input_line_ids:
+ if input_line.answer_type == 'suggestion' and input_line.value_suggested.id == label.id and (not current_filters or input_line.user_input_id.id in current_filters):
+ count = count + 1
- label_summary = {'text': label.value, 'count': count, 'answer_id': label.id}
++ if input_line.answer_type == 'text' and (not current_filters or input_line.user_input_id.id in current_filters):
++ comments.append(input_line)
++ label_summary = {'text': label.value, 'count': count, 'answer_id': label.id, 'comments': comments}
+ result_summary = result_summary + [label_summary]
+ result_summary = {'answers': answers.values(), 'comments': comments}
#Calculate and return statistics for matrix
if question.type == 'matrix':
- rows, answers, res = {}, {}, {}
+ rows = OrderedDict()
+ answers = OrderedDict()
+ res = dict()
+ comments = []
[rows.update({label.id: label.value}) for label in question.labels_ids_2]
[answers.update({label.id: label.value}) for label in question.labels_ids]
for cell in product(rows.keys(), answers.keys()):
<div class="oe_structure" />
<div class="container">
<div class="jumbotron mt32">
- <t t-set="survey" t-value="survey_dict['survey']"/>
- <h1><span t-field="survey.title"></span> <span style="font-size:1.5em;" class="fa fa-bar-chart-o pull-right "/></h1>
+ <h1><span t-field="survey.title" /> <span style="font-size:1.5em;" class="fa fa-bar-chart-o pull-right "/></h1>
<div t-field="survey.description" class="oe_no_empty" />
</div>
<div class="panel panel-default hidden-print">
controller.on('switch_mode', self, this.switch_mode);
controller.on('previous_view', self, this.prev_view);
- var container = this.$el.find("> .oe_view_manager_body > .oe_view_manager_view_" + view_type);
+ var container = this.$el.find("> div > div > .oe_view_manager_body > .oe_view_manager_view_" + view_type);
var view_promise = controller.appendTo(container);
this.views[view_type].controller = controller;
- this.views[view_type].deferred.resolve(view_type);
return $.when(view_promise).done(function() {
+ self.views[view_type].deferred.resolve(view_type);
if (self.searchview
&& self.flags.auto_search
&& view.controller.searchable !== false) {
'tag_ids': fields.many2many(
'blog.tag', string='Tags',
),
- 'content': fields.html('Content', translate=True),
+ 'content': fields.html('Content', translate=True, sanitize=False),
# website control
'website_published': fields.boolean(
- 'Publish', help="Publish on the website"
+ 'Publish', help="Publish on the website", copy=False,
),
'website_message_ids': fields.one2many(
'mail.message', 'res_id',
values = dict(values, error=error)
if error:
values.update(kwargs=kwargs.items())
- return request.website.render("website.contactus", values)
+ return request.website.render(kwargs.get("view_from", "website.contactus"), values)
try:
- values['channel_id'] = request.registry['ir.model.data'].get_object_reference(request.cr, SUPERUSER_ID, 'crm', 'crm_case_channel_website')[1]
+ values['medium_id'] = request.registry['ir.model.data'].get_object_reference(request.cr, SUPERUSER_ID, 'crm', 'crm_tracking_medium_website')[1]
values['section_id'] = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, SUPERUSER_ID, 'website.salesteam_website_sales')
except ValueError:
pass
'country_id': (0, _("All Countries"))
})
+ # format domain for group_by and memberships
+ membership_ids = product_obj.search(cr, uid, [('membership', '=', True)], order="website_sequence", context=context)
+ memberships = product_obj.browse(cr, uid, membership_ids, context=context)
+ # make sure we don't access to lines with unpublished membershipts
+ line_domain.append(('membership_id', 'in', membership_ids))
+
# displayed membership lines
- membership_line_ids = membership_line_obj.search(cr, uid, line_domain, context=context)
+ membership_line_ids = membership_line_obj.search(cr, SUPERUSER_ID, line_domain, context=context)
membership_lines = membership_line_obj.browse(cr, uid, membership_line_ids, context=context)
- membership_lines.sort(key=lambda x: x.membership_id.website_sequence)
+ membership_lines = sorted(membership_lines, key=lambda x: x.membership_id.website_sequence)
partner_ids = [m.partner.id for m in membership_lines]
google_map_partner_ids = ",".join(map(str, partner_ids))