Commit Graph
23 Commits
Author SHA1 Message Date
Gorash 5913b7265e [REF] base,*: refactor Qweb engine
* Remove AST in favor of pure Pyhon. This should make it easier for
developers to understand and create new directives because they do not
need to know AST.

* Remove `t-call-options` as it has been merged into `t-options` for more
consistency. Support for t-call-options is retained.

* Use generators for lists. This increases performances as the rendering
can be sent directly without having to wait for the creation of the
entire list.

* Optimize expressions runtime computation by pre-computing the static
parts.
Example:
'<' + 'div' + '>' + '<' + dynamic_value + '>'
Now compiles as:
'<div><' + dynamic_value + '>'
2021-08-03 15:37:54 +00:00
Victor Feyens f8b901d04b [IMP] base,web: add image_url widget support in qweb.
The new "image_url" widget logic provides the ability to provide static image
links in Char fields instead of duplicating the image file in database (+ filestore)
through an Image field (& ir_attachment).

This commits implements the frontend qweb logic for this widget, following the logic
of the existing "image" qweb widget.
2020-09-02 14:02:57 +00:00
Patrick Hoste 8c0bc4f4b8 [FIX] web: fix image widget when record name is ..
PURPOSE

Before this commit, when you used the 'image' widget when the record name was
``..`` (double dots) it couldn't retrieve the image since the double dots was
decoded as the parent directory shortcut. After this commit, the double dots
will be replaced by -- with the downside to loose the true record name.

SPECIFICATIONS

Replace the .. (double dots) with -- in the filename.

Using .. may seem like a strange use case but if you actually try to find
a partner called ".." in a production database, you might be surprised ...

LINKS

Task ID-2241513 (eLearning onboarding and testing)
PR #55567

X-original-commit: dcb7a924c36cd3f3aeef891ddd8830bd66322025
2020-08-06 15:07:37 +00:00
Christophe Simonis d74b451805 [MERGE] forward port branch 13.0 up to f4105eb9c7 2019-10-09 02:08:17 +02:00
Nicolas Martinelli 030f2654a5 [IMP] web: add support for itemprop on img
Take the following QWeb snippet:

```
<div t-field="product.image" itemprop="image" t-options="{'widget': 'image'}"/>
```

When the image is rendered, the `itemprop="image"` remains on the
`<div>` tag, it is not set on the `<img>` tag.

We add the support of the `itemprop` option, so it can be added to the
`<img>` tag:

```
<div t-field="product.image" t-options="{'widget': 'image', 'itemprop': 'image'}"/>
```

opw-2076934
2019-10-08 08:17:05 +00:00
Julien Castiaux b96e633b0b [IMP] web: upgrade the cache to use SHA2 over SHA1
SHA-1 is a cryptographic hash function that have weaknesses known since
2005, it has been deprecated by the NIST [1] about 10 years ago in 2011
and Google [2] have been able to perform a collision attack in 2017.

We use SHA-1 in order to generate unique URL for resources that can be
cached by the browser: assets bundle, translations, qweb templates and
qweb images.

Although practical attacks still requires quite a lot of computational
resources, it is time to upgrade SHA-1 to SHA-2.

We have selected the SHA-512/256 variant of the SHA-2 algorithm as
replacement for SHA-1 for the following reasons:

* On 64 bits platform, SHA-512 is the fastest SHA-2 variant, it is only
  ~1.5x slower than SHA-1. [3]
* Keeping only the 256 foremost bits protects against both collision
  attacks and length extension attacks.
* The hexadecimal digest is only 24 chars longer than SHA-1 which is
  nice to have somewhat short URLs.

We have not used SHA-3 because:

* At the moment of writing, it is too slow (~3x slower than SHA-1) [3]
* It is not guaranteed to be available with the Python 3.5 `hashlib`
  module.
* One of the author of SHA-3 is Belgian.

[1] https://csrc.nist.gov/projects/hash-functions/nist-policy-on-hash-functions
[2] https://shattered.io/
[3] http://bench.cr.yp.to/results-hash.html
[4] http://www.commitstrip.com/en/2017/02/27/the-sha-1-alternative/
2019-09-04 09:52:01 +00:00
Christophe Simonis 51354fadb0 [MERGE] forward port branch saas-12.3 up to 50e571acf7
closes odoo/odoo#36491

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-11 09:39:33 +00:00
Sébastien Theys 3a52b22b50 [FIX] web: correctly escape image name
Follow up of https://github.com/odoo/odoo/commit/2f932e3a46c6005870e4130b3c3f7151cd521f2d#r34760948

`url_quote` does not escape `/` which leads to incorrect routes when the name
contains `/`.

Also escape `\` to avoid potential issues on different OS.

closes odoo/odoo#36146

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-02 19:15:46 +00:00
Sébastien Theys d870877967 [IMP] tools,base,web,website_*: keep image ratio on resize
* = website_partner, website_profile, website_sale, website_slides

Before
======

Since commit: 2e3848b394

The images that are resized have additional borders if the target ratio is
different than the image ratio. Those borders are transparent if the image
format supports it, and are white otherwise.

With that current solution, if the background where the image is displayed is
another color than white, it is looking really bad.

Moreover, most images are stored resized like this, so it is not even possible
to decide if it should have borders or not depending on the context, the
original image and ratio is forever lost.

It is also inconsistent because if the image is already smaller than the target
size then it doesn't include borders. In that case it keeps the original ratio
instead of the target ratio. So it isn't even guaranteed that the target
ratio is going to be respected.

After
=====

This commit will solve all of those problems by always keeping the ratio of the
original image.

This implies the views should be taking care of adding borders when necessary.

task-1958000
PR: #31811
2019-04-29 13:45:03 +00:00
Sébastien Theys 2f932e3a46 [IMP] web: add filename to qweb image widget
It's better to always have a relevant name in the image URL for SEO.

Also make sure there is always an alt on the image.

closes odoo/odoo#31705

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-03-08 15:41:52 +00:00
Dharmraj Jhala 38843624d4 [IMP] web: allow preview_image option for image widget of qweb field
With this option we can define which field is going to be displayed by the qweb
image widget, while logic is still applied to the original field.

For example, we want to show a thumbnail image but when user updates it with the
web editor, we want to update the actual field instead of the thumbnail field.

This is similar to the preview_image of the JS image widget.

task-34045
PR: #30656
2019-02-14 16:03:08 +00:00
Adrian Torres 52f5528cfb [REF] *: replace deprecated pycompat helpers for builtins
This commit replaces calls to pycompat helpers that were intended for
python 2 <-> python 3 interoperability for python 3 builtins, as python
2 is no longer officially supported by Odoo.

This includes:
    * calls to imap/izip/ifilter replaced by map/zip/filter
    * uses of text_type replaced by str
    * uses of unichr replaced by chr
    * calls to implements_to_string, implements_iterator removed
    * string_types and integer_types replaced by str, int respectively
    * calls to to_native replaced by calls to to_text

This is done in preparation to the removal of these deprecated helpers
in the following commit.
2018-11-29 09:28:17 +00:00
Nimesh Jethva 2c1549cc59 [IMP]tools, technial modules: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:15 +02:00
Christophe Simonis a7a30791de [MERGE] forward port branch saas-11.4 up to a5187cef10 2018-08-27 11:16:44 +02:00
Toufik Benjaa 26084f1cc7 [FIX] web: allow to bypass postprocess on image widget
- If a CDN is used, this might cause issues for images that need access
  rights to be display.

  This is due to the fact that users are not connected on their account
  under the CDN domain, which makes the CDN requests reject since it is
  not authorized to access to those resources.
2018-08-22 15:30:52 +02:00
Raphael Collet 960360afe4 [REF] *: use native date/datetime for Date/Datetime fields
From this commit onwards, Date fields will return datetime.date objects and Datetime fields will return datetime.datetime objects, this implies a number of things that are clearly explained both in the ORM API for master.

This commit also introduces a number of helper functions for dates and datetimes that are exposed in tools.date_utils and fields.Date[time], explained in the documentation as well.

Task-ID: 47189
2018-08-06 14:37:19 +02:00
qsm-odoo de214e3742 [REF] *: BS4, 'img-responsive' -> 'img-fluid' 2018-07-27 12:36:54 +02:00
Christophe Simonis b06af028e6 [MERGE] forward port branch saas-11.2 up to d112a163cd 2018-06-28 10:55:12 +02:00
Christophe Matthieu 39f0f5db77 [FIX] ir_qweb: send template options in context to the fields
Application of a fix more specific to the problem of the contact widget
which can not serialize the dictionary because it contains the values of
the context of which browse record. (because contact try to
json.dumps options for multi-edition feature in web_editor)

opw-1859848

https://github.com/odoo/odoo/commit/ab85e9594651fd33ffd2747f4d3c5b360e7c7922
2018-06-27 15:11:37 +02:00
Christophe Simonis 40836194c2 [MERGE] forward port branch saas-11.2 up to 12ddec3a76 2018-06-27 13:41:00 +02:00
Christophe Matthieu ff3c494448 [FIX] web_editor: apply cdn for python qweb widget image
issue: widget image doe not pos processing the attributes
2018-06-15 08:42:15 +02:00
Parth Gajjar 964e16a7f5 [IMP] web: support famous 'avoid_if_small' parameter in image controller and qweb field options
Before this commit there was no option to avoid resizing images when it
was smaller than expected size. This leads to several image being displayed
with extra and unnecessary padding due to resize. This option will allow
to avoid that behavior by allowing to propagate the parameter directly
to image_resize_image.

This commit is related to task ID 31994 .
2018-03-15 11:30:53 +01:00
Thibault Delavallée 50f5d28c80 [MOV] web(_editor): move image rendering from web_editor to web
Currently the image field rendering in QWeb using the /web/image
controller is done in web_editor. However there is no link between
the web editor and the rendering. The rendering can therefore be moved
directly in web.

During the move two options have been added to the rendering of image
field :

 * qweb_img_raw_data: fallback on standard base64 behavior that is
   otherwise impossible to achieve;
 * qweb_img_responsive: True by default, add the img-responsive
   class that is not always requested;

Thanks.
2017-08-24 17:06:07 +02:00