[FIX] website_blog: hint that manual post teasers are not translatable
Since its introduction with commit [1], the blog post teaser is not translatable as the field was not set as `translate=True` by mistake. It's not possible sadly in stable to add it since the jsonb introduction for translated fields, as `translate=True` behaves as a DB change. Without a module update, it will crash, trying to set jsonb value in a non jsonb field. A best effort is make here to add a tooltip to hint what's going when in translate mode and clicking on this field text. Note that the field is not marked as translatable, but if people click on it, they will see the tooltip. If we face multiple needs, it might be clever to introduce a new property on field declaration allowing the mark a field as "translate forgotten" so that our builder shows this warning out of the box. Step to reproduce: - Install 2 langs on website - Go to /blog in the main language and enter edit mode - Type something on a blog card below the cover (it should show by default the first few sentences of the blog content) - Go to the alternate language and enter translate mode - The field is not maked as translatable and can't be translated [1]: https://github.com/odoo/odoo/commit/8cc850f3a54f62072d4df99de612f17494ffb123#diff-ae5c21b812e929930064fb93dc919ef1701fd63bae3d9fb306160d01be5629b3R114-R115 opw-3474638 closes odoo/odoo#147287 X-original-commit: abc5e3c119b74691949c7f48d3b7ba1f9fc88626 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
],
|
||||
'website.assets_editor': [
|
||||
'website_blog/static/src/js/tours/website_blog.js',
|
||||
'website_blog/static/src/js/components/*.js',
|
||||
'website_blog/static/src/js/systray_items/*.js',
|
||||
],
|
||||
'website.backend_assets_all_wysiwyg': [
|
||||
|
||||
@@ -1396,6 +1396,15 @@ msgid ""
|
||||
"of what we can see on this our closest space object."
|
||||
msgstr ""
|
||||
|
||||
#. module: website_blog
|
||||
#. odoo-python
|
||||
#: code:addons/website_blog/models/ir_qweb_fields.py:0
|
||||
#, python-format
|
||||
msgid ""
|
||||
"On your default language, empty the blog post description and save to get an"
|
||||
" automated (translated) summary."
|
||||
msgstr ""
|
||||
|
||||
#. module: website_blog
|
||||
#. odoo-javascript
|
||||
#: code:addons/website_blog/static/src/js/tours/website_blog.js:0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import ir_qweb_fields
|
||||
from . import website
|
||||
from . import website_blog
|
||||
from . import website_snippet_filter
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, models, _
|
||||
|
||||
|
||||
class Field(models.AbstractModel):
|
||||
_inherit = 'ir.qweb.field'
|
||||
|
||||
@api.model
|
||||
def attributes(self, record, field_name, options, values):
|
||||
attrs = super().attributes(record, field_name, options, values)
|
||||
|
||||
if field_name == 'teaser' and self.env.context.get('edit_translations'):
|
||||
attrs['data-translate-error-tooltip'] = _("On your default language, empty the blog post description and save to get an automated (translated) summary.")
|
||||
|
||||
return attrs
|
||||
@@ -0,0 +1,21 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import { WebsiteTranslator } from '@website/components/translator/translator';
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(WebsiteTranslator.prototype, {
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_beforeEditorActive() {
|
||||
super._beforeEditorActive(...arguments);
|
||||
$(this.websiteService.pageDocument).find('[data-translate-error-tooltip]').tooltip({
|
||||
container: this.websiteService.pageDocument.body,
|
||||
trigger: 'click',
|
||||
delay: {'show': 0, 'hide': 0},
|
||||
title: function () {
|
||||
return $(this).data('translate-error-tooltip');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user