Commit Graph
1431 Commits
Author SHA1 Message Date
Benoit Socias fdd30e368c [FIX] website: survive to null texts during trigram search
Generic search bar was introduced with #65871.
But the trigram search would fail if it encounters a (SQL) NULL text
from the database. This is because when word_similarity() receives NULL
as a parameter it returns NULL, and NULL not being a number cannot be
compared with the similarity threshold.

After this commit the trigram search will exclude matches returning a
NULL similarity.

Step to reproduce:
  - Enable trigram in the DB, run `CREATE EXTENSION pg_trgm;` in psql
  - Create a product, name it `myproduct`
  - Insert NULL values inside the translation table (not sure how the
    user did it):
    `update ir_translation set value = NULL where src = 'myproduct';`
  - Search 'mypro' in the eshop search bar
    -> Traceback

opw-2680659

closes odoo/odoo#80426

X-original-commit: ef17edc32d4646c93e31e730249be83469951241
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2021-11-26 14:26:31 +00:00
Victor Feyens b885b9e090 [REM] website: empty method override
Part-of: odoo/odoo#62249
2021-11-26 09:44:58 +00:00
Benoit Socias eab9931c11 [FIX] website: manually cascade delete from page to menu
Before this commit when a website page was deleted, its related website
menu was deleted inside the database only through the ondelete="cascade"
of the Many2one relationship. This however did not perform the menu
cleanup on the ORM side.
This caused problems when the related menu id was kept in cache by
website's _get_menu_ids(), because the record could not be fetched
anymore. E.g. deleting a website-specific version of the "Contact Us"
page caused the problem, making the menu bar non renderable on all
pages.

After this commit the caches are cleared when a page is unlinked to
avoid this problem.

task-2686221

closes odoo/odoo#80348

X-original-commit: dd9997753d442f8923b31c3ceaa0cd29b09a06b2
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2021-11-24 18:38:06 +00:00
Benoit Socias b15959c70f [FIX] website: change default template of mega menus
Before this commit the default template for mega menus was the "Multi
Menus" template.

After this commit the default template for mega menus is the "Odoo Menu"
template.

task-2675252

closes odoo/odoo#80040

X-original-commit: a4d686140133ecf59a3d09c8f930a70b91064599
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-11-18 18:45:26 +00:00
Romain Derie 8386d62702 [FIX] website: change the asset disabling from GC to CRON
Before this commit, the behavior disabling the unused snippet assets was put
directly in the autovacuum CRON instead of its own CRON.

That behavior is leading to some perf-issue running the autovacuum cron since
it would take too much time.
Indeed, the code will loop inside as many snippet as it exists, and every time
then perform an SQL Query to get the HTML fields using the snippet.

An improvement will come later to not loop on every snippet anymore.

task-2694120

closes odoo/odoo#79981

X-original-commit: 96ab95d37c9b442a4ccb737fd867ca91ec1c11b6
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-11-18 08:37:49 +00:00
Xavier Morel b51b094c2b [IMP] http: avoid cycle on request 2021-01-26 09:05:35 +01:00
Romain Derie 7d8a8ddea0 [IMP] website(_forum/_profile): remove _get_http_domain method
Before Odoo saas-14.4, one should call `_get_http_domain()` on website to get
its domain. Indeed, that method was in charge of cleaning that domain, as it
was done with commit [1].

Since Odoo saas-14.4, that cleaning is automatically performed on domain before
saving it into database, thanks to commit [2].

Thus, we can now remove the `_get_http_domain()` and use directly the domain as
it is considered clean.

Note that migrated databases coming from version older than Odoo saas-14.4
could still have an incorrect domain (trailing slash, no scheme..).
This will be handled during migration with [3].

[1]: https://github.com/odoo/odoo/commit/3ad775aab717b395a5d11527aeb3596af66afa99
[2]: https://github.com/odoo/odoo/commit/042c95b0219bb0aa13e73385e092fa76ff1a1b0a
[3]: https://github.com/odoo/upgrade/pull/2951

closes odoo/odoo#78766

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-10-21 15:47:22 +00:00
Sébastien Mottet (oms) 667a00a029 [FIX] website: use base-1 as default palette for configurator
When using the configurator the user can upload its logo to
generate a color palette. In this case we select the base-1
palette as default palette instead of the theme's default palette.
Doing so avoids the potential customizations the theme palette
may introduces.

task-2665885

closes odoo/odoo#78251

X-original-commit: 50019c8f68b89968615f87c365095c94caeef46c
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-10-13 08:41:06 +00:00
Jeremy Kersten 05dd2169a6 [FIX] website: allow to disable cache page based on content
In some case, we know that page will contains dynamic content and that cache
should be ignored.

E.g. as soon as a s_snippet_form will be present in page, we know that we need
the real csrf, and so we cannot use the cached response from another user.

Now, we disable the cache (cache_time=0)

closes odoo/odoo#77935

X-original-commit: 262499a91cc9f2365cf2ff131796d9b61b438f9b
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-10-12 11:44:44 +00:00
Romain Derie 3b0ac62a75 [IMP] website: add missing depends on is_mega_menu compute
closes odoo/odoo#78065

X-original-commit: 278a6e6c68675ad1ae820ef0a5e38407d5594e8f
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2021-10-08 16:09:27 +00:00
Tom De Caluwé 3c09208b7f [FIX] website: allow disabling themes with custom layout headers
Some themes replace the website.template_header_default template in the
website layout. This poses a problem when changing to another theme
afterwards because of the interaction between the website templates and
the _reset_default_config method:

1) Since version 15.0 the nav tag inside the header templates was
abstracted into a separate template (website.navbar) and added to each
header layout through t-call.

2) The _reset_default_config deactivates or reactivates views that were
enabled or disabled by the currently active theme. However, when doing
so, the default header is activated before the custom header is
deactivated.

As a consequence, after toggling the default header, there are
temporarily two header extensions in the website.layout template. They
both replace the //header//nav element. Because of the abstraction of
the nav element into a separate template by the header extensions, only
the first replacement will work.

task-2662497

closes odoo/odoo#77917

X-original-commit: b83a2110fd3035cc8466c4fa74f6530be5d00597
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-10-06 16:24:48 +00:00
Sébastien Mottet (oms) aaef93c017 [FIX] website: keep configurator images on theme switch
On theme switch default images of the previous theme are replaced
by the one of the new theme. For website where default images
come from the configurator we don't want them to be replaced by
the theme's images.

task-2614840

closes odoo/odoo#77648

X-original-commit: c25f80c70930f65a928b44d4fe91775c37bc4268
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-10-05 12:35:56 +00:00
Xavier Morel 17e6a69b91 [IMP] core: use Savepoint object in TestCursor
Initialize the savepoint semi-lazily (on-demand) as cycling a savepoint
generates 4~5 queries (depending whether the savepoint is explicitly
released on COMMIT or not):

    SAVEPOINT
    -- < do stuff>
    -- commit
    RELEASE SAVEPOINT -- or not
    SAVEPOINT
    -- close
    ROLLBACK TO SAVEPOINT
    RELEASE SAVEPOINT

With a lazy savepoint, this is just 0-1 queries (`SAVEPOINT` at the
first explicit query only, creating a cursor and then closing it
immediately is a no-op).

For reliability use a semi-lazy savepoint: always immediately emit a
`SAVEPOINT` on cursor creation, but don't automatically create one
after each `commit`. That limits the issues of overlapping (but
non-nested) savepoints.

Also fix the `generate` API to not use the request: when `website` was
converted to the new API, `cr`, `uid`, and `context` were dropped as
if it were a model... but it's not. So in order to recover an
execution environment, that was looked up on the session.

That, then, turns out to be an issue when `generate` is triggered from
an RPC call: the RPC layer creates its own cursor and environment
separate from the request's which may not have one at
all. Problematically during testing we're in `mono_db` mode, so the
request's cursor/env can be accessed and will be lazily initialized.

This then causes an issue with the `TestCursor`'s savepoints: rather
than be nested, the lifetimes of the request's and RPC's savepoints
only overlap[0]:

    |-- rpc --|
       |-- request --|

As a result, when the RPC's cursor is committed and released it
automatically released the request's, and the request's explicit
release then fails. This would break `/website:WithContext.test_search`.

By fixing the API of `generate`, it stops triggering the creation of a
request cursor, and therefore the overlap and resulting error.

[0] the laziness or eagerness of the savepointing in the test cursor
    has no impact on this issue, as multiple requests have already been
    issued on the RPC's test cursor before the request's is even
    created

Part-of: odoo/odoo#76243
2021-10-01 15:26:51 +00:00
Sébastien Mottet (oms) 61f71de42c [FIX] website: use snippet lists from theme manifest
Previously the configurator retrieved the snippet lists
needed to build the website pages from IAP. These lists
have been put in the theme manifests and can be accessed
from it.

odoo/design-themes#505
odoo/iap-apps#411

closes odoo/odoo#77550

X-original-commit: 01c97c697aa0c5cae79952f1d3ac8de69bf2ad1a
Related: odoo/design-themes#510
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-09-30 17:12:12 +00:00
Jeremy Kersten 653e49695e [FIX] website: svg preview has been moved in theme repo
Now, iap only return images urls needed to process the svg.
We don't need to 'download' svg preprocess, we use the svg locally and make
the substitution ourself.

It simplify the maintenance:
   Preview of theme are in theme repository
It make it blazing fast:
   Response contains a list of string, and not more a big string, the svg.

closes odoo/odoo#77199

X-original-commit: 103ec4debb539b04b1783be20f1ccf3e18ab377e
Related: odoo/design-themes#503
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-09-27 07:12:02 +00:00
Jeremy Kersten 20d6c0c7e2 [FIX] website: dynamic snippet, use lxml.html to process rendered view
t-field of a Text field, will use nl2br function that replace \n to <br>.
So it is html that we need to parse.

Add one return line in your sale description, and the rendering will fail
with an error opening and ending missmatch for br...

closes odoo/odoo#77108

X-original-commit: 3b3f9b24362e57b4c1538d8377ef4de5f3d65058
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-09-24 11:08:56 +00:00
Xavier Morel 5e81361f80 [FIX] *: opt parent_path fields out of unaccent
closes odoo/odoo#76436

Related: odoo/enterprise#20822
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-09-20 12:53:01 +00:00
Xavier Morel b043d9fa64 [IMP] core, website: add psycopg2.sql support to get_unaccent_wrapper
`website` added its own sql-compatible version of
`get_unaccent_wrapper` in order to use `psycopg2.sql` for safety.

That is very sad.

Add a condition in the "standard" unaccent wrapper which checks
whether the input type is a `Composable`, and in that case return an
`SQL`. This increases the cost of the wrapper a tad but probably not
to a really sensible amount.

Task 2634851

Part-of: odoo/odoo#76436
2021-09-20 12:53:00 +00:00
Kamen Zhekov db3acb5ef9 [FIX] website: correctly set and sync custom account setting
A while back, the behavior of this setting was changed from a
related field to a computed as a fix to various issues with: cb9f48d
The setting's value synchronization with what is displayed on the
setting's page is broken, since its behavior changed with commit:
2ccc735 . It resets to its default value for the default website when
editing a secondary one and is not only confusing but breaks the
setting in some scenarios.

When changing the auth_signup_uninvited setting, the changes
are correctly reflected and not reset to default upon changing
the website we are currently editing.

task-2612686

closes odoo/odoo#76538

X-original-commit: 6e7a0664850ccbc30a7a8a3ced22f05347bc6f9e
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-09-15 10:16:47 +00:00
Sébastien Mottet (oms) 905df37c8b [FIX] website: add support for svg logo in configurator
The configurator's palette selection screen didn't support
SVG logo. On SVG upload primary and secondary colors couldn't
be extracted and no palette was recommended. It comes from the
fact that Python PIL library does not support SVG. We therefore
had to convert SVG to PNG before trying to extract primary and
secondary colors. A file format checking has been added. If the
uplodad file is not an image, a notification is displayed to
the user.

task-2602521

closes odoo/odoo#76400

X-original-commit: 33f43618f727bdc1239c52c66b73f0f436035774
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-09-13 14:42:54 +00:00
Raphael ColletandXavier Dollé 1595c0ee27 [REF] core: replace thread-local "envs" by cursor-bound "transaction"
Refactor the Environments object into a Transaction object, which is
bound to one cursor, and is no longer shared among several cursors.

The following methods/properties have been changed:
 - Environment.envs no longer works (because of the design change);
 - Environment.manage() is deprecated (no longer useful);
 - Environment.reset() is now an instance method;
 - env.clear_upon_failure() is deprecated in favor of cr.savepoint().

closes odoo/odoo#75598

Related: odoo/enterprise#20451
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Co-authored-by: Xavier Dollé <xdo@odoo.com>
2021-09-03 15:45:46 +00:00
Oussama MESSAOUDIandqsm-odoo 7e8ba9bc2f [IMP] website, *: review the header templates + add CTA as an option
*: portal, website_sale, website_sale_wishlist

Part of https://github.com/odoo/odoo/pull/68149
task-2368576

Part-of: odoo/odoo#68149
Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-09-03 14:29:51 +00:00
Benoit Socias b88bb72beb [IMP] website: search inside translated pages
Before this commit the search on pages was only done in the main
language.

After this commit the search on pages is based on the translated "arch"
field.

task-2379555
https://github.com/odoo/odoo/pull/65871

Part-of: odoo/odoo#65871
2021-09-03 06:59:33 +00:00
Benoit Socias 9f9c4bb7e4 [IMP] website(_*): replace search callbacks by a mixin
Before this commit the `_search_get_detail` result contained callback
functions to handle special behavior during fetching and rendering.

After this commit a `website.searchable.mixin` is introduced that must
be inherited by models that participate in website-based searches.
Custom behavior previously achieved with callbacks is now achieved by
overloading methods of this mixin.

task-2379555
https://github.com/odoo/odoo/pull/65871

Part-of: odoo/odoo#65871
2021-09-03 06:59:33 +00:00
Benoit Socias c6ba756e4b [IMP] core, website: use fuzzy matching in web-based search
Before this commit searched terms were the ones entered by the end-user.

After this commit if the searched term is not found then the search is
performed on a resembling term.
The similarity is obtained from a Levenshtein distance combined with
ratios of common and different letters.
By default the dictionary against which the search term is matched is
based on the content of the search fields containing a word that starts
with the first letter of the search term.
If the `pg_trgm` Postgresql extension is installed the dictionary is
built from matches using the `<%%` operator (similar to the
`word_similarity` function).
Several approaches were benchmarked during development, those results
are available through the task record.

task-2379555
https://github.com/odoo/odoo/pull/65871

Part-of: odoo/odoo#65871
2021-09-03 06:59:33 +00:00
Benoit Socias 7559626c54 [IMP] website, *: make a generic search bar snippet available
(*: website_blog, website_event, website_forum, website_sale,
website_slides)

Before this commit the search bar was specific to products.

After this commit a generic search bar is available as a general feature
of website which can be configured to inspect specific models.
The snippet is used to replace the old search bar in blog, courses,
event, forum, page and shop.
The search results of these pages and the autocomplete of the search bar
run through the same search mechanism.
A new hybrid results page has also been created as a target of a search
on "Everything".

In each involved module, `website._search_get_details()` is implemented
to return search metadata for every model related to the `search_type`
parameter.
Search metadata for a single model is returned by `_search_get_detail()`
on that specific model.

The autocomplete runs through the additional
`website._search_render_results()` pre-rendering step that prepares the
data to fit in the autocomplete template.

task-2379555
https://github.com/odoo/odoo/pull/65871

Part-of: odoo/odoo#65871
2021-09-03 06:59:33 +00:00
Younn Olivier fa1c05e7bb [IMP] website: disable assets for unused snippets
Based on their path, we retrieve snippets assets, assuming that it will
be in the form : /snippets/{snippet_id}/{version}.{scss|js}

Then we check the template definition uses that version, or if any views
or html fields contains a snippet with such version exist.
If not, the asset is deactivated.

For that, we are looking for the data-snippet attribute in snippets
already dropped. For the template definition, we look at the first class
definition if a data version attribute is also defined.

task-2212216

closes odoo/odoo#73005

Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2021-09-02 14:14:56 +00:00
Louis Wicket (wil) 80d74e7ee0 [IMP] mail, web, *: add support for guest users
* = crm_livechat, hr, hr_holidays, im_livechat, mail_bot, purchase, sms,
    snailmail, survey, test_discuss_full, test_mail, web_editor, website,
    website_livechat

 - Create new model `mail.guest` for guests.
 - Rewrite some RPCs to target routes rather than model methods so that
   guests are able to use them.
 - Patch JS and python models to support guests.
 - Create a stand-alone page and boot the channel in it.

task-2494829

closes odoo/odoo#75496

Related: odoo/enterprise#20417
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-09-02 00:43:34 +00:00
Sébastien Mottet (oms) 23915c7113 [IMP] website: add saas version in calls to website.api.odoo.com
The saas version of the client is added in each call to
website.api.odoo.com. This allows the server to return
different results based on the client's saas version

task-2602521

closes odoo/odoo#75617

X-original-commit: 6e1ae856584048912cb5eaf53c0aa027b2342b5c
Signed-off-by: Sébastien Mottet <smottet@users.noreply.github.com>
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-08-26 10:21:38 +00:00
qsm-odooandBenoit Socias a48a30f954 [IMP] website, web_editor, *: allow to use pre-configured gradients
*: web

After this commit pre-configured gradients can be used as snippet
backgrounds, snippet filters or as text effects / highlight effects.

The background colors (and now gradients) are now possible to add
*alongside* a color combination class (editing one does not remove the
other). Background colors and gradients are mutually exclusive.

Part of https://github.com/odoo/odoo/pull/73611
task-2599770

closes odoo/odoo#73611

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: Benoit Socias <bso@odoo.com>
2021-08-17 17:43:50 +00:00
Ivan Yelizariev 0f3ea5e1f4 [FIX] website: allow edit robots.txt to non-first website
Previous implementation always updated *current website*, which is not
always the same as the value from `res.config.settings`.

---

opw-2623007

X-original-commit: d66d44db031be76403ce7c01616e334ef196fd03
2021-08-17 11:03:09 +00:00
Jeremy Kersten d310a7adc6 [IMP] website: handle images_preview_theme for recommended_themes
closes odoo/odoo#74887

Related: odoo/design-themes#482
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-08-10 09:37:48 +00:00
Martin Trigaux c7bac3dee0 [IMP] *: make ir.model.data helper private
No reason to interfact with them directly in RPC
2021-08-10 13:49:04 +02:00
Romain Derie cfe4a47702 [REM] website: remove unused compute
The field was removed with 15aae7ea34

closes odoo/odoo#74875

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-08-09 15:10:26 +00:00
Gorash 7df343dd1b [IMP] base: QWeb _render return Markup unicode instead of utf8 bytes
In order to limit encoding decoding, the _render method returns a
unicode string in the markup safe object instead of a MarkupSafeBytes

closes odoo/odoo#68299

Related: odoo/upgrade#2454
Related: odoo/enterprise#17270
Signed-off-by: Antony Lesuisse (al) <al@openerp.com>
2021-08-03 16:20:22 +00:00
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
15aae7ea34 [IMP] website: organize links in menu & footer on configurator apply
The configurator takes care of the organization of the links to the different
pages. Some links are put in the menu and some are put in the footer. The order
is predefined. If too many links are present in the menu then a sub-menu 'Company'
is created and some links are put in it. For the 'News' and 'Succes Stories' features
a website specific blog is created.

Links have the following order in the menu and are present only if their corresponding
website.configurator.feature has been selected in the configurator excepted for the 'Home'
and 'Contact us' links which are default links:
- 'Home'
- 'Shop'
- 'Event'
- 'Courses'
- 'Services'
- 'Pricing'
- 'Company': if more than 8 links in menu and more than 1 item in this submenu
             otherwise the three following links are in the top menu.
  - 'News'
  - 'Success Stories'
  - 'About us'
- 'Appointment'
- 'Contact us'

Links in footer:
- 'Privacy Policy'
- 'Help': if website_helpdesk installed. This is not a website.configurator.feature.
- 'Forum'

Community: https://github.com/odoo/odoo/pull/71993
Enterprise: https://github.com/odoo/enterprise/pull/18930

task-2518565

Co-authored-by: Sébastien Mottet (oms) <oms@odoo.com>
Co-authored-by: Romain Derie <rde@odoo.com>
Co-authored-by: Jeremy Kersten <jke@odoo.com>
2021-07-30 13:51:33 +00:00
Romain Derie 59098dbc60 [FIX] website: avoid commit, reset env, reload registry for no reason
Before this commit, if the configurator was applied without a module to install
it would still go through `_button_immediate_function()` which does

```
self._cr.commit()
api.Environment.reset()
modules.registry.Registry.new(self._cr.dbname, update_module=True)
```

for no reason, even if `self` is an empty module recordset.

This code is taking ~5 seconds.

This flow will occur when you either:
- Create a new website when selecting only page feature
- Create a new website when some modules feature are already installed

Community: https://github.com/odoo/odoo/pull/71993
Enterprise: https://github.com/odoo/enterprise/pull/18930

task-2518565
2021-07-30 13:51:25 +00:00
Arthur Detroux (ard)andqsm-odoo 1c442782f8 [IMP] website, *: add visibility options on sections
*: web_editor

Provide the user with an option to hide or display a section tag
depending on the visitor's location (if geoip enabled), language,
utm_medium, utm_source and utm_campaign.

Users can use a M2M widget to select different records. These will be
used to create a CSS selector on save that will hide the section tag
depending on the various options they selected.
This CSS selectors will be applied, as well as various data attributes
when the page loads to hide the targeted tag. All of these operations
are handled client side.

The geoip country had to be added to the session for the feature to work
with countries.

Part of https://github.com/odoo/odoo/pull/67140
task-2381049

closes odoo/odoo#67140

Related: odoo/enterprise#19907
Related: odoo/upgrade#2658
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-07-30 14:03:42 +00:00
Romain Derie 26dee545aa [FIX] website: unset menu/page m2o if menu url is a controller
Setting a controller URL to a menu which is linked to a page should unset the
m2o relationship to preserve the page URL.

Step to reproduce:
  - Create a page (with a menu) and save, eg: "My Page" (url will be /my-page)
  - Edit that new menu and change the URL to /shop (or any controller)

Issue:
  - The page URL is now /shop, which doesn't have a lot sense if there is a
    controller for that URL.
  - Unpublishing the website.page will unpublish the menu, as a menu needs its
    page to be published in order to be visible.

Note: The flow introduced here is the same as if you choose an URL of an
      already existing page, the menu's page will be unlinked from the menu and
      left with its original URL.

task-2575974

closes odoo/odoo#74163

X-original-commit: b52a01f76d89ebb7bdd75577e60a09f048c83000
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2021-07-26 17:34:19 +00:00
Jeremy Kersten fa40411a33 [FIX] website: remove ir.asset specific on unlink
New system of ir.asset doesn't clear specific website asset on uninstall.
Now when we delete a website, we delete relate ir.asset.

task-2611030

closes odoo/odoo#74180

X-original-commit: 4e2df51a5f57bb8dde792e59295c20f3104bf4e2
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-23 15:24:41 +00:00
Jeremy Kersten f0a484f7ae [FIX] wesbite: fix wrong encoding from page generated by configurator
Before this commit, some snippets that contains special charactere like –
was wrongly displayed, since we removed the call to pycompat that did a
decode('utf-8') in previous version.

closes odoo/odoo#74041

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-20 13:14:06 +00:00
Jeremy Kersten 02df207a04 [FIX] website: configurator set custom image as public
Before this commit, overrided images was not visible if not logged in.

How to reproduce
----------------
Install a theme with configurator to have custom image of industries.
Log out
You have original image instead of industries

closes odoo/odoo#73921

X-original-commit: d1241379a7c5f999b7a82ca290dd8b5f212a0997
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-16 16:55:14 +00:00
Xavier Morel e84a72767e [FIX] website: de-traw-ify dynamic snippets
Mark the fragments as markup-safe after fetching them.

Also make _render private (don't see any reason for it to be publicly
accessible), and avoid unnecessary intermediate enc/dec in it.
2021-07-20 05:45:52 +00:00
Matthieu Stockbauer f8882698e8 [MOV] website, website_form, *: merge website_form app into website
*: crm_iap_lead_website, website_crm, website_form_project,
   website_hr_recruitment, website_sale

Part of https://github.com/odoo/odoo/pull/69888
task-2462993
2021-07-16 19:13:18 +00:00
Jeremy Kersten f7c43b4343 [FIX] website: parse result of_render as html
`_render('<h1> quick &amp; flupke </h1>') `=>` '<h1> quick & flupke </h1>'`
what cannot be parsed in xml after.

Before this commit, if you try to install a page that contains a '&' via
the configurator, you had a traceback:
   xmlParseEntityRef: no name, line 1, column 13

closes odoo/odoo#73509

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-09 14:42:10 +00:00
Jeremy Kersten 478068c829 [IMP] *: always use Odoo Response
This branch adds request.redirect on all requests.
In case of a front end request, we do an url_for to the location.

We removed redirect_with_hash that was only for retro compatibility

local_redirect has been renamed to redirect_query, and param keep_hash has been
removed and moved.

Default code for redirect is 303 now instead of 302.

Now redirect and redirect_query make local redirect by default, you need to
pass local=False to make external redirect.

All werkeug.utils.redirect has been replaced by request.redirect.

Http.redirect now use an http.Response type, and it become easy to add an
override like 'set_cookies' e.g.

Dispatch of a website.page return an http.response too, so we first need to
check if it is a cached version before to check if it is an Odoo Response.

Migrate your code:

http.redirect -> request.redirect(location, code, local)
http.local_redirect -> request.redirect_query(location, query, code, local)
http.redirect_with_hash -> request.redirect

Courtesy of odony for help and review ;)

closes odoo/odoo#72599

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-08 07:00:06 +00:00
Benoit Socias efc470cbff [IMP] website: validate 308 redirections parameters
Before this commit 308 redirections could be configured with a malformed
route which made the routing fail.

After this commit 308 redirections validation makes sure all parameters
of URL from appear in URL to and no other parameter appears.

task-2451780

closes odoo/odoo#73457

X-original-commit: a0e9384f1e674a140b9ddb3424fed5a43155dd01
Signed-off-by: Romain Derie <rdeodoo@users.noreply.github.com>
2021-07-08 18:10:09 +00:00
Sébastien Mottet (oms) 84f8a30e1f [IMP] website: rename website_type_preselection field
Rename field website_type_preselection to website_config_preselection since feature
preselection is not only based on website type anymore but also on website purpose.

task-2518565

closes odoo/odoo#73377

Related: odoo/enterprise#19498
Related: odoo/upgrade#2625
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2021-07-08 07:36:12 +00:00
Thibault Delavallée 0d755e7127 [IMP] website: improve returned data from Website.new_page(..)
Purpose is to have more detailed information given back when calling new_page.
Now each new record adds its entry in returned result:

  * view_id: new ir.ui.view created. As there is always a view (based on a
    template) it is now always set, and not only when creating a page;
  * page_id: set if ispage is true, ID of website.page created;
  * menu_id: set if add_menu is true, ID of website.menu created;

Previously only view_id was returned when creating a page which can be a
limitation notably in website_event.

Task-2577079
PR odoo/odoo#72411
2021-07-07 08:27:54 +00:00