[FIX] *: use html_translate for non-sanitized html fields

Commit c21568e14f deactivated the sanitization of frontend html fields so
that their modification through the editor worked again. However,
this broke the possibility to display their traduction and to modify
them.

The problem is that the translate option of html fields should not
equal "True" but instead be the html_translate function defined in
openerp.tool.translate. The translate=True option is automatically
change in html_translate though but there is a condition: the field
should be sanitized, which is why this broke since the sanitization
is disabled.

This commit sets the translate option of non-sanitized html fields
to html_translate. Maybe we should investigate for this to be automatic
for non-sanitized html fields as well.

Thanks to @rco-odoo.
This commit is contained in:
qsm-odoo
2016-07-19 17:02:02 +02:00
parent 946b9415cd
commit 7aa9f23955
6 changed files with 19 additions and 16 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import pytz
from openerp import _, api, fields, models
from openerp.exceptions import AccessError, UserError
from openerp.tools.translate import html_translate
class event_type(models.Model):
""" Event Type """
@@ -171,7 +172,7 @@ class event_event(models.Model):
readonly=False, states={'done': [('readonly', True)]})
country_id = fields.Many2one('res.country', 'Country', related='address_id.country_id', store=True)
description = fields.Html(
string='Description', oldname='note', translate=True, sanitize=False,
string='Description', oldname='note', translate=html_translate, sanitize=False,
readonly=False, states={'done': [('readonly', True)]})
# badge fields
badge_front = fields.Html(string='Badge Front')
+2 -2
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from openerp import models, fields, api
from openerp.tools.translate import _
from openerp.tools.translate import _, html_translate
from openerp.addons.website.models.website import slug
@@ -44,7 +44,7 @@ class event_track(models.Model):
state = fields.Selection([
('draft', 'Proposal'), ('confirmed', 'Confirmed'), ('announced', 'Announced'), ('published', 'Published'), ('refused', 'Refused'), ('cancel', 'Cancelled')],
'Status', default='draft', required=True, copy=False, track_visibility='onchange')
description = fields.Html('Track Description', translate=True, sanitize=False)
description = fields.Html('Track Description', translate=html_translate, sanitize=False)
date = fields.Datetime('Track Date')
duration = fields.Float('Duration', digits=(16, 2), default=1.5)
location_id = fields.Many2one('event.track.location', 'Room')
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from openerp.osv import osv, fields
from openerp.tools.translate import html_translate
class hr_job(osv.osv):
_name = 'hr.job'
@@ -18,5 +18,5 @@ class hr_job(osv.osv):
return super(hr_job, self).job_open(cr, uid, ids, context)
_columns = {
'website_description': fields.html('Website description', translate=True, sanitize=False),
'website_description': fields.html('Website description', translate=html_translate, sanitize=False),
}
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from openerp import api, models, fields
from openerp.addons.website.models.website import slug
from openerp.tools.translate import html_translate
class ImLivechatChannel(models.Model):
@@ -16,4 +17,4 @@ class ImLivechatChannel(models.Model):
res[channel.id] = "/livechat/channel/%s" % (slug(channel),)
return res
website_description = fields.Html("Website description", default=False, help="Description of the channel displayed on the website page", sanitize=False)
website_description = fields.Html("Website description", default=False, help="Description of the channel displayed on the website page", sanitize=False, translate=html_translate)
+8 -8
View File
@@ -10,7 +10,7 @@ import datetime
import openerp.addons.decimal_precision as dp
from openerp import SUPERUSER_ID
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp.tools.translate import _
from openerp.tools.translate import _, html_translate
class sale_quote_template(osv.osv):
@@ -18,7 +18,7 @@ class sale_quote_template(osv.osv):
_description = "Sale Quotation Template"
_columns = {
'name': fields.char('Quotation Template', required=True),
'website_description': fields.html('Description', translate=True, sanitize=False),
'website_description': fields.html('Description', translate=html_translate, sanitize=False),
'quote_line': fields.one2many('sale.quote.line', 'quote_id', 'Quotation Template Lines', copy=True),
'note': fields.text('Terms and conditions'),
'options': fields.one2many('sale.quote.option', 'template_id', 'Optional Products Lines', copy=True),
@@ -108,7 +108,7 @@ class sale_order_line(osv.osv):
_inherit = "sale.order.line"
_description = "Sales Order Line"
_columns = {
'website_description': fields.html('Line Description', sanitize=False),
'website_description': fields.html('Line Description', sanitize=False, translate=html_translate),
'option_line_id': fields.one2many('sale.order.option', 'line_id', 'Optional Products Lines'),
}
@@ -157,7 +157,7 @@ class sale_order(osv.osv):
_columns = {
'access_token': fields.char('Security Token', required=True, copy=False),
'template_id': fields.many2one('sale.quote.template', 'Quotation Template', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
'website_description': fields.html('Description', translate=True, sanitize=False),
'website_description': fields.html('Description', translate=html_translate, sanitize=False),
'options' : fields.one2many('sale.order.option', 'order_id', 'Optional Products Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, copy=True),
'amount_undiscounted': fields.function(_get_total, string='Amount Before Discount', type="float", digits=0),
'quote_viewed': fields.boolean('Quotation Viewed'),
@@ -320,7 +320,7 @@ class sale_quote_option(osv.osv):
'template_id': fields.many2one('sale.quote.template', 'Quotation Template Reference', ondelete='cascade', select=True, required=True),
'name': fields.text('Description', required=True, translate=True),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True),
'website_description': fields.html('Option Description', translate=True, sanitize=False),
'website_description': fields.html('Option Description', translate=html_translate, sanitize=False),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),
'discount': fields.float('Discount (%)', digits_compute= dp.get_precision('Discount')),
'uom_id': fields.many2one('product.uom', 'Unit of Measure ', required=True),
@@ -389,7 +389,7 @@ class sale_order_option(osv.osv):
'line_id': fields.many2one('sale.order.line', on_delete="set null"),
'name': fields.text('Description', required=True),
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)]),
'website_description': fields.html('Line Description', sanitize=False),
'website_description': fields.html('Line Description', sanitize=False, translate=html_translate),
'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')),
'discount': fields.float('Discount (%)', digits_compute= dp.get_precision('Discount')),
'uom_id': fields.many2one('product.uom', 'Unit of Measure ', required=True),
@@ -455,6 +455,6 @@ class product_template(osv.Model):
_inherit = "product.template"
_columns = {
'website_description': fields.html('Description for the website', sanitize=False), # hack, if website_sale is not installed
'quote_description': fields.html('Description for the quote', sanitize=False),
'website_description': fields.html('Description for the website', sanitize=False, translate=html_translate), # hack, if website_sale is not installed
'quote_description': fields.html('Description for the quote', sanitize=False, translate=html_translate),
}
+3 -2
View File
@@ -11,6 +11,7 @@ from urlparse import urlparse
from openerp import api, fields, models, SUPERUSER_ID, _
from openerp.tools import image
from openerp.tools.translate import html_translate
from openerp.exceptions import Warning
from openerp.addons.website.models.website import slug
@@ -30,7 +31,7 @@ class Channel(models.Model):
}
name = fields.Char('Name', translate=True, required=True)
description = fields.Html('Description', translate=True, sanitize=False)
description = fields.Html('Description', translate=html_translate, sanitize=False)
sequence = fields.Integer(default=10, help='Display order')
category_ids = fields.One2many('slide.category', 'channel_id', string="Categories")
slide_ids = fields.One2many('slide.slide', 'channel_id', string="Slides")
@@ -98,7 +99,7 @@ class Channel(models.Model):
string='Channel Groups', help="Groups allowed to see presentations in this channel")
access_error_msg = fields.Html(
'Error Message', help="Message to display when not accessible due to access rights",
default="<p>This channel is private and its content is restricted to some users.</p>", translate=True, sanitize=False)
default="<p>This channel is private and its content is restricted to some users.</p>", translate=html_translate, sanitize=False)
upload_group_ids = fields.Many2many(
'res.groups', 'rel_upload_groups', 'channel_id', 'group_id',
string='Upload Groups', help="Groups allowed to upload presentations in this channel. If void, every user can upload.")