Commit Graph
165 Commits
Author SHA1 Message Date
Julien Mougenot 3e3dce0eb8 [REF] *: rename assets 'glob' to 'path'
Rationale:
The majority of cases where an ir.asset is manually declared
outside of manifest files is to specifically add a single asset file.
This means developers are specifying a single asset *path*, and not a
glob expression. In this context, it seems better to name the filepath
field `path`, and document that it can be specified with a glob
expression when (seldom) needed, rather than making the exception appear
to be the norm - possibly puzzling many developers (What's a glob and
why do I need one?)

The doc is updated as well, and some spell-checking and wording
improvements were done too.

This required some adaptations to the existing `ir.asset` declarations:
- odoo/enterprise#17465
- odoo/design-themes#459

closes odoo/odoo#68695

Related: odoo/upgrade#2348
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2021-04-07 20:39:10 +00:00
8cc066173d [IMP] *: Improve assets management
This commit changes the way assets are declared in Odoo modules.

Before: assets were declared in template files. Template bundles were
generated from primary templates, so technically any qweb template could
have been called as an asset bundle, with the 't-call-assets' directive.

Being standard qweb templates, they had access to standard HTML tags
(script, link, with or without raw scripts or style definition), qweb
directives (t-call, t-raw, etc.) and could be inherited by other
templates.

Now: assets are defined in the module's manifest and generated by the
't-call-assets' directive.

More information on the new system can be found on the updated user
documentation (see the "JavaScript Reference" section).

Task: 2352566

Co-authored-by: Bruno Boi <boi@odoo.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Simon Genin <ges@odoo.com>
2021-03-31 13:57:17 +02:00
Romain Derie 9dab9ffce2 [IMP] web_editor: show error if uploaded image type is not suported
We only support .gif, .jpe, .jpeg, .jpg, .png, .svg

This commit won't let the code go though if we know the image format is not
suported.

Part of https://github.com/odoo/odoo/pull/65828
task-2345082
2021-03-31 07:07:31 +00:00
Jeremy Kersten f09c84c022 [FIX] base, web_editor, website: add missing encoding on etree.tostring
Since lxml 4.5.0 that use now use libxml2 2.9.10, without it, it can crash.

Here sample of content that is broken:
https://drive.google.com/file/d/1gB2-jl4fabHscLjH9OZc4WZgtSEbCVj7/view?usp=sharing

note: this commit is to merge 3 changes of #64526

opw-2428617
opw-2428664

closes odoo/odoo#66883

X-original-commit: 38983d123d171ac3cc1efacd99d9776f0ed08734
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-26 07:55:25 +00:00
Jeremy Kersten 1d5634ba8a [FIX] base, web_editor: don't crash on deleted records
task-2458109

closes odoo/odoo#66023

X-original-commit: 550043b6c36cf657e6cee229676a95ee6482e421
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-02-11 19:52:25 +00:00
Benoit Socias 1044a76a19 [IMP] web_editor, test_website: allow renaming custom snippet blocks
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

closes odoo/odoo#61483

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-03 15:13:19 +00:00
Nasreddin (bon) 82ca092bd1 [FIX] misc: Babel; handle 'kur' (kurdish) locale
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

closes odoo/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>
2021-01-10 19:59:01 +00:00
Benoit Socias 1feebf2a4d [FIX] web_editor: review public_render_template
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

closes odoo/odoo#64167

X-original-commit: 3fd40ba2030fef7dccf4046a932e3b3a172dc53f
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-06 17:01:34 +00:00
Benoit Socias bde8abcfeb [IMP] web_editor: support 5 dynamic colors for illustrations
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

closes odoo/odoo#60503

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-11-20 13:13:15 +00:00
Samuel Degueldre b1654e5b2b [FIX] web_editor: fix issues related to loading image info
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.

closes odoo/odoo#60982

X-original-commit: b0993370b6fcec1f966e4bf2994eee7f31da82d5
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-10-29 12:27:13 +00:00
Harpritsinh Sisodiyaandjpr-odoo 7c3cb51e52 [FIX] web_editor: fix oe_structure view that are not in extention mode
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
closes odoo/odoo#55908

closes odoo/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>
2020-10-06 16:35:59 +00:00
qsm-odoo faf51a373b [FIX] web_editor: make sure [data-snippet] is added on internal t-call
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
2020-08-18 17:39:29 +00:00
qsm-odoo c5fee9d009 [FIX] web_editor, *: restore custom snippets thumbnails
*: 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/b7fe2bdae2f45372c0d538767a226a413b806f3f

closes odoo/odoo#55896

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-08-13 15:44:48 +00:00
xO-Txandqsm-odoo 41527531b7 [IMP] web_editor, *: add snippets search filter
*: website

Add a search bar at the top of the "Blocks" tab to filter snippets.

Part of https://github.com/odoo/odoo/pull/55272
task-2309832

closes odoo/odoo#55272

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2020-08-13 14:29:20 +00:00
Samuel Degueldre 2e81f53a2a [FIX] web_editor: add index on original_id to improve delete performance
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)

closes odoo/odoo#54676

X-original-commit: 2b5064a00b7a5c8dc66429869287386f244b1257
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-07-17 13:31:22 +00:00
Nicolas Lempereur 4c4a0eab95 [FIX] web{site,_editor}: oe_structure save clean data-oe-*
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 #53321

closes odoo/odoo#53346

X-original-commit: 855438be92ee71d8f8d5afedd52459e149ec49f7
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-06-19 14:51:34 +00:00
fja-odoo 049745c5ff [FIX] web_editor: fix _view_get infinite recursion
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.

closes odoo/odoo#51620

X-original-commit: 63e1e84ebd7e609d6e06d83dc0f0092688b013eb
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-05-20 13:20:35 +00:00
Martin Trigaux d9287caf94 [IMP] *: convert to private methods
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.
2020-05-14 13:59:10 +02:00
Martin Trigaux 56a8c9e431 [FIX] *: add sudo when accessing views
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.
2020-05-14 13:59:10 +02:00
fja-odoo 11c60739e4 [IMP] website, *: warn user about outdated blocks
* = 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

closes odoo/odoo#50254

X-original-commit: 28a6cd49b6e87b75c2e70771e241c41778bf9e87
Related: odoo/enterprise#10236
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-04-27 16:36:31 +00:00
qsm-odoo e4a7103517 [FIX] web, web_editor: allow editor instantiation from public user
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/48981

closes odoo/odoo#48981

closes odoo/odoo#49398

X-original-commit: e84a0bfdc99c21406861b88c02b11c925d92f927
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-04-10 11:54:03 +00:00
Samuel Degueldre bf9d864fb0 [FIX] website: fix logo not supporting new image url format
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.

closes odoo/odoo#48914

X-original-commit: 9c618c7f903f1a0b32e067cfd713cd39762250f9
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-04-02 18:49:03 +00:00
Samuel Degueldre 807ac81144 [IMP] web_editor, *: set image alt automatically, remove useless alts
*: 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
closes odoo/odoo#45174

Related: odoo/enterprise#9520
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-03-30 11:07:10 +00:00
Samuel Degueldre 02e71a1a3c [IMP] web_editor: add unique to image URLs to leverage browser caching
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
2020-03-30 11:06:48 +00:00
Samuel Degueldre 49ea7b2b41 [IMP] web_editor: improve image optimization workflow in media dialog
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
closes odoo/odoo#45174
2020-03-30 11:06:48 +00:00
Jeremy Kersten 4c40393490 [FIX] website: perf - translation - avoid query to find what we know
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
2020-03-19 15:37:47 +00:00
alt-odoo b0be65f211 [FIX] web_editor: crash in date formatting if no langage set
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.

closes odoo/odoo#46487

X-original-commit: 67cf1150507b8092c32bf745e4c8620409fdc238
Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
2020-02-27 20:04:06 +00:00
Romain DerieandJeremy Kersten 4eafd78847 [FIX] web_editor, website: handle date edition in all lang and format
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 #44484
Closes #45555
Fixes #44047

closes odoo/odoo#45725

closes odoo/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>
2020-02-21 18:57:59 +00:00
Xavier Morel de590816d8 [FIX] *: deprecated access to url_ utilities through werkzeug root
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.
2020-02-04 12:42:35 +00:00
Jason Van Malder 5b252215dc [FIX] web_editor: replace root style/class attrib
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

closes odoo/odoo#44541

X-original-commit: 8579c0cae839c615415120b79d6ec22c71f7affd
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-02-04 08:00:14 +00:00
fja-odooandqsm-odoo 218e1cad61 [IMP] web_editor, *: allow saving of snippets
* 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

closes odoo/odoo#40408

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2020-01-16 14:29:04 +00:00
fja-odoo 47441a9228 [FIX] web_editor: save all child text nodes of oe_structure elements
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

closes odoo/odoo#43375

X-original-commit: eb71d25ce965ecdb20c26517627aed5b43f8b990
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-01-15 17:46:02 +00:00
Nicolas Lempereur d138a708a0 [FIX] web_editor: Revert "update attribute of edition container"
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

closes odoo/odoo#42599

X-original-commit: da62f7e65bd1df67138fe9a82000f800dc0ff84c
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-02 13:56:54 +00:00
Nicolas Lempereur 1c47f2070b [FIX] web_editor: update attribute of edition container
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 #40345

closes odoo/odoo#40830

X-original-commit: 71b20a24c40ae9daa10076ab0fd656b043819cff
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-11-25 18:10:30 +00:00
Mohammed Shekha 7291021152 [FIX] web_editor: traceback on saving the product
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

closes odoo/odoo#40638

X-original-commit: 896127a6528fa59f7f385019e296acd5db585321
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-11-26 05:11:50 +00:00
jvm-odoo 6188378e57 [FIX] web_editor: fix wrong datetime parsing
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.

closes odoo/odoo#40415

X-original-commit: d00c0e317f8affbe8bea231972c2b6da70b9f240
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
2019-11-18 11:35:19 +00:00
qsm-odoo 53bb4582d2 [FIX] web_editor: do not show website name in snippet names
Since https://github.com/odoo/odoo/commit/ea3a2ab6788980a8961d9b9a3f88bc13c15a3c46
the website name appears in the view names if the user has the multi
website group or in special cases on some form views.

We don't want it to be displayed in snippet names in the editor UI.

Part of https://github.com/odoo/odoo/pull/38495
task-2083198

closes odoo/odoo#38549

X-original-commit: 3ad50aa53f1f8673a674365917f95e75b036f244
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2019-10-11 22:34:41 +00:00
Julien Castiaux 4f03a5f136 [FIX] *: remove old deprecated modules/functions
PEP-594 is deprecating a bunch of modules. As part of the cleanup, we
are also dealing with long deprecated modules, functions and aliases.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`
* `assertRegexpMatches` -> `assertRegex`
* `base64.encodestring` -> `base64.encodebytes`
* `base64.decodestring` -> `base64.decodebytes`
* `inspect.getargspec` -> `inspect.signature`
* `inspect.formatargspec` -> `inspect.signature`
* `logging.warn` -> `logging.warning`

closes odoo/odoo#36863

Task: 2003936
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17 11:36:42 +00:00
Martin Trigaux b4faa5d70c [FIX] base,web_editor: fix typo
Remove redundant _description
2019-08-28 09:55:34 +00:00
Christophe Simonis d5e1fd16b4 [MERGE] forward port branch saas-12.4 up to cda4f3c308 2019-07-29 14:10:30 +02:00
Christophe Simonis bfd34e14b1 [MERGE] forward port branch saas-12.3 up to 40e8b67179 2019-07-26 15:12:29 +02:00
Christophe Simonis a4b1b532ea [MERGE] forward port branch 12.0 up to b82df99d7a 2019-07-25 20:01:05 +02:00
Romain Derie 6a59224055 [FIX] web_editor, website: avoid returning children of inactive view
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

closes odoo/odoo#35154

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-24 15:38:42 +00:00
Romain Derie bac4b43a23 [FIX] web_editor, website: remove unused param
`_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.

closes odoo/odoo#35157

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-24 16:06:27 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
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'`
2019-07-17 14:13:12 +02:00
Adrian Torres 9e71d57d11 [REM] *: remove calls to api.one and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
2019-07-05 09:04:45 +00:00
Thanh Dodeur c212cfe899 [REF] *: removes datas_fname from ir.attachment
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 #1909865

closes odoo/odoo#32976

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-06-05 09:12:13 +00:00
Sébastien Theys 87a35d4263 [IMP] web, web_editor, *: add media image optimize dialog
* = 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
2019-06-04 22:14:13 +02:00
Sébastien Theys 76cf2ae82a [IMP] web_editor, *: improve media dialog attachment upload
* = 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
2019-06-04 22:14:13 +02:00
Christophe Simonis 71faa19af0 [MERGE] forward port branch saas-12.1 up to 2b3296bbf8 2019-03-11 14:42:34 +01:00