When you save your custom snippet you probably won't give it a
specific name.
Before this commit several custom snippets name was specified on save
and there was no way to modify their name afterwards
After this commit custom snippets are assigned a generated name but they
can be renamed afterwards
task-2374802
closesodoo/odoo#61483
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Issue
- add a new language with locale code KUR (for Kurdish)
- print any report with a datetime on it (RFQ for example)
Cause
Babel (version < 2.7.0) does not handle locale "KUR".
Solution
If wrong locale or not managed by Babel, try to fallback
on server default locale.
If still wrong locale or not managed, then fallback on "en_US" as locale.
opw-2416482
closesodoo/odoo#64304
X-original-commit: e6ccdb397792db62c3b08d96435b3c1667c1aa9d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
The normal flow to render a template is now to use `render_public_asset`
which bypasses the read access rights if the user matches the groups
the view declares.
For public users, we still cannot use that as they do not have access
to calling model methods at all. The route `public_render_template` is
thus still needed, but it should use the `render_public_asset` util.
Related to task-2412544
closesodoo/odoo#64167
X-original-commit: 3fd40ba2030fef7dccf4046a932e3b3a172dc53f
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Before this commit only the first default palette color was configurable
on illustrations
After this commit all 5 default palette colors are configurable on
illustrations
task-2368585
closesodoo/odoo#60503
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
In order to allow modifying background images, we need information on
the image, this is done by creating a placeholder img and calling the
loadImageInfo function on it. However this function did not account for
the case where an image had not src attribute, which causes an
unnecessary rpc. Other problems could arise from this as an attachment
that doesn't have the correct mimetype but has a matching src could be
returned, causing its image_src field to be false, which we would then
attempt to load as a valid image, causing crashes.
This commit fixes that by not trying to load image infos when the src of
an image is empty, only looking for attachments of the supported
mimetypes, and also checking that we actually did receive an image_src
before setting it as the original src of the image, which will prevent
accidentally trying to load a falsy src as an actual image.
closesodoo/odoo#60982
X-original-commit: b0993370b6fcec1f966e4bf2994eee7f31da82d5
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Issue occurs due to the way we compute the default value in base ir ui view.
The method _compute_defaults don't set extention mode under some condition
even if we provide an inherit_id view.
This commit double fix it, we use now self.env['ir.ui.view'] to create the
new view and so always compute the mode based on 'if inherit id or not'.
Second fixes is to explicitely set mode manually as 'extention'.
before commit:
when you drop snippet to blog sidebar and click save button.
The changes of user is not visible in sidebar because view created in mode
'normal' and not 'extention'
task-2311520
closesodoo/odoo#55908closesodoo/odoo#59318
X-original-commit: a944ce9beaaf984a7b1282785d03d4bfc8220f18
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Co-authored-by: jpr-odoo <jpr@openerp.com>
Since [1], an attribute is added on all snippet contents, on the main
node, to be able to identify them and better support them. This is
added thanks to the t-snippet or the t-snippet-call instruction. The
problem was this was not working if the first node of the snippet
definition is also a t-call to another sub template. This now works.
[1]: https://github.com/odoo/odoo/commit/11c60739e4f4379a61581ed179bc7debbb5e91f9
task-2276740
PR #53175
*: website
Since [1], the thumbnails of the saved snippets were not right anymore,
all fallbacking to the default image. This is because snippets thumbs
now use svg files instead of png and the snippet saving feature did not
allow it. This commit fixes that and makes the feature more robust.
- Allow to use any original thumbnail, and not only for website app.
- Remove useless defaut image, a fallback for when the feature is broken
is useless.
- Identify snippets by key instead of by main class (possible since
the new `data-snippet` attribute on snippets).
[1]: https://github.com/odoo/odoo/commit/b7fe2bdae2f45372c0d538767a226a413b806f3fclosesodoo/odoo#55896
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
In #45174, the original_id field was added on ir.attachment, so that
derived images in the web-editor (cropped, resized, optimized, ...)
could keep a trace of the original, such that if the user wanted to
revert it or change the crop/size/optimization parameter, we could do it
from the original again so that for example the quality can be increased
or the crop region made bigger.
The addition of this self-referencing many2one from ir.attachment to
itself however will cause DELETE queries on ir.attachment to do a
sequential scan on the table to update potential records referencing the
deleted record in their original_id field. As the ir.attachment table
tends to be one of the biggest tables in production databases (millions
of records), this scan can take multiple seconds per DELETE operation,
and since attachments are used everywhere in odoo to represent files,
DELETE operations on them are frequent.
Adding an index on the original_id field should make these DELETE
operations substantially faster (scaling with the log of the number of
filled original_id fields, which will be very small, instead of scaling
linearly with number of records)
closesodoo/odoo#54676
X-original-commit: 2b5064a00b7a5c8dc66429869287386f244b1257
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Since dd139948f0 when saving oe_structure for the first time, for eg.
a `<div class="oe_structure" id="oe_structure_part_1"/>` structure, when
edited we will create an inheriting view that fills it.
But this inheriting view would contain branding data and "data-note-id"
which would make this use case erroneous:
- edit page and fill oe_structure => data-note-id="1" saved on view
- edit page and add link in other oe_structure => error
This happen because the data-note-id refers to the editor of the
element currently being edited, since we saved it previously we get two
elements with `data-note-id="1"` and the code will just get the first
one which in reality could have not been in editing.
With this change, we strip the branding data on the parent element.
Without the change, added test failed with:
AssertionError: '<div class="oe_structure" data-test="1"
id="oe_structure_test" test="2">hello</div>' not found in
'<t t-name="dummy"><div class="oe_structure" data-test="1"
id="oe_structure_test" data-oe-id="55" test="2">hello</div>
</t>' :
saved element attributes are saved excluding branding ones
opw-2268836
closes#53321closesodoo/odoo#53346
X-original-commit: 855438be92ee71d8f8d5afedd52459e149ec49f7
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
The _view_get function is a recursive function used to retieve all the
views related to a view (inherited or t-called).
The issue is that by an odd set of circumstances it is possible to have
a loop in the view graph. Resulting in the recursive function being
called until a "maximum recursion depth exceeded" error occurs.
Example of a loop: A t-call B and A inherit from B
This is possible on an update of a view that has been forked by website:
If the view A was doing a t-call on B and is has been duplicated with
the arch modified.
When we update with the changes A now inherit from B instead of t-call B
Since the arch was modified it will not be updated so A will still
t-call B but the inherit_id of A is unchanged so it will be updated to
reference B resulting in a loop.
closesodoo/odoo#51620
X-original-commit: 63e1e84ebd7e609d6e06d83dc0f0092688b013eb
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
render, render_template, load, activity_schedule_with_view,
get_website_pages should all be private:
It should not be possible to render an aribtrary template only with
its name or id
Still need to render some qweb views from js so the method
render_template is kept public.
This explains why the website editor still need read access on
ir.ui.view as we want to allow any snippet to be rendered.
The method fields_view_get should be the only way to retrieve the view
content. This method is executed in a super-user context.
To avoid retrieving views for a model a user does not have access to
(as it may reveal some informations like name of fields), add a
verification of 'read' rights before retrieving the view content.
Execute _postprocess_access_rights with sudo(False) as this method is
used to evaluate which buttons should be displayed.
Remove the su flag to avoid misleading the user and displaying a
button they won't be able to use.
Retrieving the database id from an view key is not considered as a
sensitive information and get_view_id and viewref can be left as a
public methods.
Add missing sudo when needed
Change _handle_visibility in website to avoid increasing the query
count: Checking the visibility (to fail most of the time) to retry in
sudo was making unecessary queries.
* = mass_mailing, web_editor, website_crm, website_event, website_form,
website_forum, website_hr_recruitment, website_mail_channel,
website_mass_mailing, website_sale, website_slides
When an outdated snippet's option are activated we display a warning
in the left panel that inform the user about the potential
malfunctions.
To do so the snippet's template key is added to the snippet as
data-snippet.
If a snippet is "t-call" inside another snippet, it will need to use
t-snippet-call instead of t-call to have the key on himself.
Those unique keys are used on snippet selection to retrieve the
snippet's version in the left panel and compare it with the currently
selected snippet's version. Versions are describe with data-vcss,
data-vjs and data-vxml. If a snippet's key is not in the left panel we
consider that snippet as outdated.
Added some tests to ensure that t-snippet and t-snippet-call really have
their template key as data-snippet
Adapted the views to the data-snippet changes adding
data-snippet="tmpl_key".
Part of: https://github.com/odoo/odoo/pull/44569
task-2189669
closesodoo/odoo#50254
X-original-commit: 28a6cd49b6e87b75c2e70771e241c41778bf9e87
Related: odoo/enterprise#10236
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
If for some reason someone wanted to develop a textarea using the
editor which is supposed to work as a public user (like we are trying
to do on Odoo.com), it was not possible. The code was "designed" to
allow it but there was one problem: the lazy loading of the editor
assets required a `render_template` call to the server... which cannot
be done from a public user.
This commit solves the issues by allowing the lazy loading of assets
to use a custom route if required. That route is then used by the editor
"root". That route performs the render_template as a superuser provided
that the view's xmlid is whitelisted.
Note: there was another unauthorized call for public user: the
colorpicker. This was solved by disabling the colorpicker template rpc
for public user, they will still get the default summernote one.
Part of https://github.com/odoo/odoo/pull/48981closesodoo/odoo#48981closesodoo/odoo#49398
X-original-commit: e84a0bfdc99c21406861b88c02b11c925d92f927
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
In a recent commit, we decided to change the image url format generated
by the media-dialog to leverage browser caching using unique.
Unfortunately, when saving an img tag to a binary field, the url parsing
did not support this new url format, causing a traceback when changing
the website logo and attempting to save.
closesodoo/odoo#48914
X-original-commit: 9c618c7f903f1a0b32e067cfd713cd39762250f9
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
*: website, web_unplash
The html alt attribute is supposed to contain a description of an
image's content (an alternative to the visual representation), a lot of
snippets contained alt attributes that were not descriptive of their
content, and would as such be counter-productive in terms of
accessibility. This commit removes those.
Previously, the alt attribute on img tags had to be set manually by the
user through the editor. This commit makes use of the description field
on ir.attachment to store image description, and sets the alt attribute
on images to that description when choosing an image from the media
dialog.
task-2091417
closesodoo/odoo#45174
Related: odoo/enterprise#9520
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Previously, image urls did not contain the unique parameter, this
resulted in all browser caching for images being dependent on etag
headers. This commit changes the url format used by images in the
web_editor to use the /id-checksum/ format instead of only the id, this
in turn makes it so that the 'Max-age' header is set to 1 year. This
also solves some browser caching issues when changing the optimization
level of an image in place in the media-dialog.
For binary attachments with an url (eg, unsplash images) the unique is
added as a search parameter (?unique=checksum) as a cachebuster
mechanism, but currently doesn't set the max-age header, which may or
may not be done at a later date.
task-2091417
Previously, when selecting an image, the user could optimize their
images by clicking a little cog icon in the media dialog. They would
also be prompted to optimize their images when uploading them. In most
cases, it makes a lot more sense to always save the original in the
database, and optimize the original whenever it's dropped in the page
automatically.
A second problem is that when using the optimization feature, optimized
images would be displayed along the originals by default, resulting in a
lot of duplicates while browsing the media dialog.
This commit changes both of these things:
- By default, when uploading an image, the original uploaded image is
used. The user can still optimize their image manually through the
media-dialog by using the cog icon. When choosing an image in the
media-dialog, if it's not already an optimized image, an optimized copy
is automatically created and used instead.
- Optimized images are now hidden by default, in the media dialog, and
can be shown by clicking a checkbox at the top of the modal when in
debug mode
task-2091417
closesodoo/odoo#45174
Before this commit, each module override _get_translation_frontend_modules_domain
from ir.http to add its own translation in website if needed and that module
is not starting by website_. Updating the domain from the super() call.
Since we know in most of the case the name, it is useless to do a:
select name from module where name = 'name1' or name = 'name2'...
Now we support a new override of _get_translation_frontend_modules_name that will
allow to add the known module name directly in the list instead to make a search.
In case nobody override _get_translation_frontend_modules_domain, we don't need to
make an extra rpc to find the module.
Related to #47257
task-2211013
X-original-commit: 0dc54814161ab55c34dd2242f65dea23d19fdfca
This issue was introduced with commit 251b880de1caeeef1f27447d4ad69e1abeffde19 : in case current user has no langage,
we should have a fallback case by retrieving the first langage installed in the database.
closesodoo/odoo#46487
X-original-commit: 67cf1150507b8092c32bf745e4c8620409fdc238
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
Before d00c0e317, `Datetime` fields would be editable in frontend but would
have unexpected results, especially in non-English languages, for when the
english lang format had been changed.
It would also crash when saving non-English strings, such as `Lundi`.
For more details, see https://github.com/odoo/odoo/pull/44484#issuecomment-586850490
Since d00c0e317, only date displayed in lang format would be editable, which
case is Event page in Odoo 12.0. Everywhere else, the format is changed for a
nicer layout, either with `widget=XXX` or `t-options=YYY`, such as:
`<time t-field="record.date" t-options='{"format": "MMM d, yyyy"}'/>`
`<time t-field="record.date" t-options="{'time_only': 'true', 'format': 'short'}"/>`
When a date parsing crashes during editor save, the problem is not only that
the date can be saved, but the whole changes of the page are lost, as they
won't be saved either.
This commit attempts to fix every languages cases, regardless of the website
lang or user lang.
To do so, we store the date in the user lang format in a data attribute of
every date field in the DOM. Once the field is clicked (to edit probably),
that value will replace the one displayed according to the widget/options.
That way, dates will always be sent to the server in the user lang format,
avoiding any possible mismatch.
This whole fix apply to `Datetime` and `Date` fields.
opw-2183055
Closes#44484Closes#45555Fixes#44047closesodoo/odoo#45725closesodoo/odoo#45997
X-original-commit: c0db9bb8027ff926c619aebe6e0a5cdd05808232
Original-signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Co-authored-by: Romain Derie <rde@odoo.com>
Co-authored-by: Jeremy Kersten <jke@odoo.com>
In 0.15 accessing werkzeug.urls functions directly through werkzeug
is deprecated, the shortcut will be removed in the eventual werkzeug
1.0.
Fix existing uses of these shortcuts. Also cleanup some imports when
they're not far from a werkzeug* import being altered.
Issue
- Install eLearning
- Edit the header > change image
- Save
Image not changed
Cause
We do not take new style/class attrib in account in
replace_arch_section.
Solution
Take them in account
OPW-2122947
OPW-2182109
closesodoo/odoo#44541
X-original-commit: 8579c0cae839c615415120b79d6ec22c71f7affd
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
* website, mass_mailing, website_event, website_form,
website_mass_mailing, website_sale
Now the user can save snippets to use them on other pages.
task-2120409
closesodoo/odoo#40408
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
When saving the content of an oe_structure, the starting text nodes
were lost because only the internal *elements* were considered. Ending
text nodes were kept since they are considered as the last element's
tail by the etree library.
task-2040764
closesodoo/odoo#43375
X-original-commit: eb71d25ce965ecdb20c26517627aed5b43f8b990
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This reverts commit 404fa816403b60c0d6e36bef6f2c73f020ea5ff3.
The commit acts on some special case. But it seem to break some case
when there is a t-ignore or other directive at that same element.
Reverting because a good solution would need to take
into account t-attr-class and this might not be possible easily.
opw-2122947
closesodoo/odoo#42599
X-original-commit: da62f7e65bd1df67138fe9a82000f800dc0ff84c
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
In most use case, when we edit the website we have a situation such as:
```
<div id="wrap" branding-attributes="...">
<section class="mycontent">hi!</section>
</div>
```
When we modify a part, we replace all child nodes of the branded
element.
But if we had more complex content such as:
```
<div id="wrap">
<section class="mycontent" branding-attributes="...">ho!</section>
<t t-call-assets="web.assets_common" t-js="false" t-css="false"/>
</div>
```
we have a t-call inside the div#wrap, so branding is distributed to
child that could have attribute modified (eg. changing background).
Then if `<section/>` node is saved, the possibly modified attributes
are lost.
Without the change, the added test fails with:
'<div class="nice">hoi</div>' not found in '...<div>hoi</div>...' :
saved element attributes are saved excluding branding ones
opw-2122947
closes#40345closesodoo/odoo#40830
X-original-commit: 71b20a24c40ae9daa10076ab0fd656b043819cff
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
before this commit: when creating a product from frontend and editing
the product and delete image and save edition, it throws traceback,
because ir.qweb.field.image doesn't get any url and due to which it
throws traceback.
after this commit: if url is not defined in ir.qweb.field.image field
converter then return None
task-2063293
closesodoo/odoo#40638
X-original-commit: 896127a6528fa59f7f385019e296acd5db585321
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Reproduce the issue
- Install Events
- Set the english default format date to %d/%m/%Y
- Create an event & edit the date
The date is set correctly in the backend
- Edit the date of an event on the website directly
The date format is still the old one
Cause
The `from_html` method of DateTime was using `parser.parse` and
ignore the user's date format.
This commit changes `parser.parse` into `datetime.strptime` taking
into consideration the user's date format.
closesodoo/odoo#40415
X-original-commit: d00c0e317f8affbe8bea231972c2b6da70b9f240
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
Before this commit, for the following view tree:
P (active)
|
I (inactive)
|
II (active)
When calling `get_related_views()` on 'P', it would wrongly return 'II'.
It shouldn't, since its parent 'I' is inactive.
Step to reproduce:
- Go to /shop
- Enable ecommerce categories
- Enable Collapsible Cateogories
- Disable ecommerce categories
- Collapsible categories is still shown even if its parent got archived
closesodoo/odoo#35154
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
`_view_get_inherited_children()` `options` parameter is not more useful.
Introduced with ae8232136d and not used since edce2fd6d0.
Also, the opportunity is taken to rename `options` in `_views_get` into
`get_children. Indeed `options` does not mean much.
closesodoo/odoo#35157
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.
Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
This commit removes the field `datas_fname` from `ir.attachment` as
it was unnecessary and most of the time the duplicate of `name` or
`url`.
Task #1909865closesodoo/odoo#32976
Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
* = website, website_blog
The goal is to give the user an opportunity to optimize his images before using
them.
For this we introduce a preview/configuration dialog after every image upload,
where appropriate default values are filled for the quality and resolution,
based on where the image is going to be used. Since this is not going to be
perfect all the time, we still allow the user to configure them, and we display
a preview to ease this process.
Indeed it is important for SEO and for usability in general that the images are
as light as possible in size.
Technically the original image is uploaded and saved first, and then it can be
optimized. This way the upload only happens once, and the preview can be
computed from the already saved image.
task-1930726
PR: #31208
* = web_unsplash, website
Remove iframe upload and replace it with a proper RPC. The route is now only
accepting one file at a time, which makes it easier to maintain, and allows to
process the first file as soon as it is ready, instead of having to wait on
everything.
Also fix a bug where a document could not be uploaded because it would try to
parse it as an image.
Remove filter after search result from the JS and add the corresponding
conditions in the domain to avoid processing and returning unnecessary records.
If multiple attachments exist with the same URL, now display them all to avoid
confusion.
Compute all the necessary values in the python model instead of in the JS.
Allow SVG in the widget (the server already accepted them before).
Disable multiple image upload when not in multiImages mode.
task-1930726
PR: #31208