Commit Graph
17 Commits
Author SHA1 Message Date
Raphael Collet 34d6f87d54 [REF] core: put field.depends on registry and make field.recursive explicit
The attributes field.depends and field.depends_context are problematic
for sharing fields across registries, because they depend on the model's
registry class, which may vary from one registry to another.  In order
to make computed fields shareable, we have to move those values away
from fields.

For the same reason, field.recursive should not be inferred, because its
value may depend on the registry, although it is generally not the case.
Moreover, the flag recursive=True is set on a field when field triggers
are determined (on the registry).  A compute method may be called before
the flag is set (if no update has been done yet), and that can lead to
incorrect computations.

This happened in test TestUsers2.test_reified_groups in module 'base'.
The user groups view was apparently determined without the flag being
set, and the view depends on the recursive field 'trans_implied_ids',
which was not correctly computed.

We thus force developers to be explicit about recursive computed fields.
The code now logs a warning when the flag is not set up properly.
2021-05-03 12:33:29 +00:00
Francois (fge) 402740f73e [ADD] web: add /web/assets for assets bundle
Part of PR 63177
2021-02-15 10:55:00 +01:00
Raphael Collet b951579d31 [FIX] core: non-stored binary fields should have attachment=False
This prevents some code (in controllers) to retrieve an attachment for a
field that is not stored, as the code only relies on `field.attachment`.
This also makes the field definition more consistent.

closes odoo/odoo#57980

X-original-commit: 7325c3f8c538a8b8c0435963cdda3ced6fe4b324
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-09-17 16:54:02 +00:00
Victor Feyens 2f3dcb8947 [IMP] base,website*: do not store country flags.
1) Avoid the storage of all country flags as ir_attachment (230+
ir_attachment in a new db) to reduce the filestore of databases.

The country flags are nearly static and not expected to be modified on
Odoo instances.

This change is based on the new "image_url" widget logic (see previous commits).

2) Extend the flag coverage for countries

Add the missing country flags & specify a mapping to provide flags
for overseas administrated countries/territories.
2020-09-02 16:43:45 +00:00
Jeremy Kersten cbf8d3b304 [IMP] website: perf - cache public page
closes odoo/odoo#56331

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-08-21 17:50:00 +00:00
Raphael Collet e1f514f100 [FIX] website: adapt query count
closes odoo/odoo#54878

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-07-24 08:30:00 +00:00
Raphael Collet a6c43e0366 [FIX] website, website_blog: adapt tests
closes odoo/odoo#52865

X-original-commit: ae268ec99e25d246593b3996981b4287a0ed3081
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-11 15:26:29 +00:00
Romain DerieandJeremy Kersten 30f4f610bf [IMP] website: improvement regarding social image
This commit introduce multiple improvements regarding social image:
  - (perf) Don't read ir.attachment through `social_default_image` when it is
    not needed. Use a stored boolean to know if the field should be accessed.
    This will remove one SQL query in attachment for public user.
  - Show website logo, not the company logo since we now have a different logo
    for website.
  - Don't show images lower than 200 width or 200 height px. Logo will be
    shown regardless of his size.
  - Don't show website logo if there is a website social_default_image.
    Indeed, the spec was to prevent showing logo and social_default_image if
    they are the same image. Technically, this is hard to identify as they
    could be the same image uploaded with different resolutions (media dialog),
    especially if one of those was uploaded through the backend and one from
    the frontend.
    It is most likely we will never correctly identify duplicate as they won't
    be exactly the same.
    For this reason, it makes more sense to hide the website logo if the
    social_default_image is set. It avoids every issues while it makes sense
    since you won't want to use the logo over the social_default_image. If you
    really want to, you could reupload it through the SEO media dialog.

closes odoo/odoo#47848

Related: odoo/upgrade#1012
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-03-30 16:06:13 +00:00
Jeremy Kersten 26c4de2f18 [IMP] http_routing: use cached code from lang
In case of short controller that don't use qweb template, we don't need
anyhting else that this url code that don't change frequently.

It make only sense for model like lang, website, ... that will not change
frequently. And are called on each call by the dispatcher.

In case of a website page, we will btw browse lang later, but in case of
small controller like /favicon.ico, or page without qweb, ... we can just
use the same from last query.
2020-03-26 18:12:47 +00:00
Jeremy Kersten 1606d22d40 [FIX] base: perf - binary_record, don't rebrowse ir.attachment
If model is already an ir.attachment we don't need to do a new search_read.
We can use it record directly.

After this commit, we don't do extra request if we already have the info,
else we don't change the behavior.

task-2211013
2020-03-26 18:12:47 +00:00
Jeremy KerstenandRomain Derie 6d6b505598 [IMP] website: perf - add cache for website frequent fields
The dispatching layer of Odoo (common to any call) can avoid a query on website
if those 3 values are cached.
Note that for complex business flows, there won't be any gain since website
infos will have to be fetched at some point.

About user_id:
In most cases, for a website page you will need to browse the website btw so
we don't remove this request previously. But in case of a simple image, the
controller /web/content need the public user just to set the request.uid in
auth_public but no other info from website.

With this commit, we don't do the 'select * from website where id in()'
request on each controller declared in auth='public' but use the user_id
from the cache. (Invalidated by the write on website_id)

task-2211013

Co-authored-by: Jérémy Kersten <jke@odoo.com>
Co-authored-by: Romain Derie <rde@odoo.com>
2020-03-26 18:12:50 +00:00
Romain Derie bd4a44cece [IMP] base: perf - try/except instead of exists
Most of the time, the record exists, but we still ensure it does, every single
time, making an SQL query.
Doing a try catch will result in the same behavior, but won't make that query
most of the time.

task-2211013
2020-03-26 18:12:47 +00:00
Romain Derie 2c09e00a64 [IMP] website: perf - prefetch menus when serving a page
If we are rendering a page, the menus will most likely be rendered as well.
Note that even in a 403 case when the page is found but is not visible, the
menus will also be shown on the 403 page.

Fetching the menus before accessing the requested page will prefetch that page
as well in one go if that page is in the menus, without any costs for the pages
not in the menus.

There is a tradeoff for 'non-layout' pages, which only occurs in advanced
technical cases:
1. Create a page with specific extension as name suffix (page.css) in which
   case the page will be bootstraped accordingly, without call to layout.
2. Remove the call to layout in HTML editor or backend
3. Remove the call to submenus template in HTML editor or backend
For those cases, the menus will be prefetched for no reason.

Note that homepage '/' is rendered through a controller, same logic is applied
there.

task-2211013
2020-03-26 18:12:47 +00:00
Romain Derie d52c2bbe19 [IMP] website: perf - clear cache only when needed
Before this commit, the cache would always been cleared even if not needed.
Now, we only clear cache when needed.

Util:
Introduced with https://github.com/odoo/odoo/commit/9920f20e4c7753bc17bea71dea3a90f7de687196#diff-1407a8ce197a04eefaefa26c127a4418R327
Changed with 0d5fcdc1c7

task-2211013
2020-03-26 18:12:47 +00:00
Romain Derie a5a57321c7 [IMP] website: perf - reduce SQL queries for the website menu
Render page flow:
  - Search website.page in _serve_page for requested URL
  - Check if the page is visible with `is_visible`
  - `is_visible` will get the `ir.ui.view` of the page
    Note that this is not 'cachable' as being visible depends of now() for the
    publishing date
  - Render layout which is getting the website menus
    Note that this can't be cached either as a menu visibility might also
    depends of it's website.page visibility which depends of now()
  - Checking menus `is_visible` fetch the menus pages and those pages views.

Before this commit, every level of menu hierarchy would add 2 queries.
This can be avoided by prefetching everything in once during the dispatch if we
know we will render the website menu.
In such a case, read `is_visible` on every website menus will fetch every
pages, views and menus in the lowest SQL queries possible, eg one query for
every table.

For a 3 level menus, requests goes from 20 to 12 to load a untracked page.

task-2211013
2020-03-26 18:12:47 +00:00
Romain Derie af68fcde48 [IMP] website: clean and add perf tests
- Refactor for easier readability
  - Add a test to ensure menu hierarchy scale correctly.
  - Add tests for image controllers
  - Add test for assets controllers

task-2211013
2020-03-26 18:12:47 +00:00
Romain Derie ffd6ebff72 [FIX] website: add SQL performance test for page loading
This will ensure the performances stay correct for a blank page (no layout),
a standard page and a homepage (which has its own controller).

Related to #47257
task-2211013

X-original-commit: 08e01b5fc4a71b8f7639a953137fbb546ddf3b3e
2020-03-19 15:37:49 +00:00