Commit Graph
999 Commits
Author SHA1 Message Date
Christophe Simonis b82df99d7a [MERGE] forward port branch saas-11.3 up to 5f419d4ad3 2019-07-25 18:38:32 +02:00
Christophe Simonis e4a4b5a8f0 [MERGE] forward port branch 11.0 up to 0375c0174d 2019-07-24 16:04:59 +02:00
Jairo Llopis 21ede5365a [FIX] website: Delete redirections if website is deleted
Before this patch, if a website is deleted, its redirections will stay, affecting other websites.

Now, website-specific redirections will disappear along with their corresponding website.

closes odoo/odoo#35130

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-24 10:16:43 +00:00
Romain Derie cd7d3a7671 [FIX] website: be able to save settings when monosite multicompany
Before this commit, `language_ids` field would be required through python code.
It is the only website res settings field that is required=True.

That's an issue since the website settings can be empty if there is no readable
website. In that case, the settings won't save.

Website res settings should be set as required XML side, in the view,
conditionned on the fact there is a website selected or not.

For the reason why there is not always a website selected, see bb473003d7.

closes odoo/odoo#34706

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-09 14:03:17 +00:00
Pragya Ladda bd49d9c0cf [IMP] website: cannot deactivate language used by website
closes odoo/odoo#31520

---

backport of 8e2f9a4fe2
Initially a improvement, it is now backported in 12.0 to fix #34430

closes odoo/odoo#34474

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-07-01 08:59:28 +00:00
Nans Lefebvre ea064c81c9 [FIX] website: fix access error at settings save
Let a database with company C1, C2,
and a website W belonging to C1, used for both companies.
Settings in C2 cannot be saved without setting a website.
At settings load W is removed from C2 because it belongs to C1.
So reset C2's website to W.
This triggers a (useless) write of company_id (C1.id) on W.
Then we have w.user_id.company_id.id != self.env.user.company_id.id, (C1 != C2).
So if contacts are not shared, then accessing w.user_id.company_id would cause
an access error because of record rules, preventing the save.
As a result, settings are unusable for company C2.

opw 2008887

closes odoo/odoo#34102

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-06-13 12:41:15 +00:00
Nicolas Martinelli 16f9375dab [FIX] website: website-specific child views
On a eCommerce page were there was no SEO optimization change:
- Customize > Activate "eCommerce categories"
- Customize > Activate "Colapsible category list"
- Promote > Optimize SEO > Change description > Save

Nothing happens.

Actually, an SQL error is raised because of the `ondelete='restrict'`
set at:

https://github.com/odoo/odoo/blob/897feb553e6ef75af9434cb77436b26abde3a761/odoo/addons/base/models/ir_ui_view.py#L212

In this case, we have the following structure:

```
View 1
|
---> View 2 (Website-specific)
|
---> View 3 (Website-specific)
```

For example:

```
Products
|
---> eCommerce Categories (Website-specific)
|
---> Collapsible Category List (Website-specific)
```

Since the inherited view (View 2) is website-specific, we duplicate it
and try to unlink it. However, this view has children, which raises the
error.

To solve the issue, we re-attach the children of the inherited view to
its copy. In a realistic situation, the children of a website-specific
view should also be website-specific, so there is no need to apply the
'copy or re-attach' logic recursively.

We end up with:

```
View 1 (Website-specific, duplicated)
|
---> View 2 (Website-specific, duplicated)
|
---> View 3 (Website-specific)
```

opw-1997946

closes odoo/odoo#33787

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-06-04 08:30:08 +00:00
Christophe Simonis 4c61621efb [MERGE] forward port branch 11.0 up to 9a7e3c8b49 2019-04-08 17:45:00 +02:00
Romain Derie 90dec44a28 [FIX] website: restore the add of website_id on user at signup
Since b5a12b4aac the website_id was not set anymore.

Indeed, before this commit website_id was the field from the inherits, thus
when writing on website_id from res.user, we would write on the partner field.

But with b5a12b4aac the website_id was explicitely overrided on res.users as a
related to res.partner (its inherits) with readonly=True.

Thus, writting website_id on res.users was not working anymore.

closes odoo/odoo#33521

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-21 10:01:58 +00:00
Romain Derie c209c250d7 [FIX] website: prevent new website homepage to be '/-1'
Before this commit, the URL of the bootstraped homepage for a new website
could be '/-1' instead of '/'.

Indeed, creating a new website ends up calling `page.copy` which try to get an
unique URL for the website (to avoid duplicated URL after copy). Typically, the
copied page will have a suffix (-X).

But `get_unique_path` in charge of doing that is based on `get_current_website`
method which will/could return a wrong website (not the one we created).
For instance the one forced in session after using the website switcher or
creating a website or installing a theme.

As those website already have (most likely) a homepage '/', get_unique_path
will create the bootstraped homepage with '/-1' as URL.

Step to reproduce (among others):
- Create a new website in backend through res.settings screen
- Create another new website, it's homepage will be '/-1'.
- Repeat indefinitely, every two website created, the bug will appear.
(One out of two, the bug won't appear since it will try to get an unique URL
on the previously created website which only has '/-1' so '/' is assumed
unique)

closes odoo/odoo#33372

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-05-14 15:12:50 +00:00
Nicolas Lempereur 8557bcfa30 [FIX] website: language prefixed URL on website bis
Reintroduces 5324284f5 that was reverted because in the case of an URL
like /payment_stripe/static/src/js/stripe.js directly inside a QWeb
template, we would possibly get:

  /fr_FR/payment_stripe/static/src/js/stripe.js

Which is not accepted by werkzeug SharedDataMiddleware we use to serve
static data in /{module_name}/static/ directories.

Added test without changeset failed with:

- test_process_att_no_request_lang: <AssertionError>
  line: self._test_att('/en_US/', {'href': '/'})
  wrong result: {'href': '/en_US/'}
- test_process_att_with_request_lang: <AssertionError>
  line: self._test_att('/', {'href': '/fr_FR/'})
  wrong result: {'href': '/'}
- test_process_att_matching_cdn_and_lang: <AssertionError>
  line: self._test_att('/en_US/a', {'href': 'http://test.cdn/a'})
  wrong result: {'href': 'http://test.cdn/en_US/a'}
- test_process_att_no_route: <AssertionError>
  line: self._test_att('/my-page', {'href': '/fr_FR/my-page'})
  wrong result: {'href': '/my-page'}
- test_process_att_url_crap: <IndexError: list index out of range>
  line: request.httprequest.app._log_call[-1],

opw-1922051
closes #32095

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-04-02 14:45:24 +00:00
Christophe Simonis 3e54704e66 [MERGE] forward port branch 11.0 up to 27081bf6f5 2019-03-05 17:26:04 +01:00
Adrian Torres 21a95bae50 [FIX] website: properly unlink website_id ir.model.field
It is not properly unlinked because it is a m2o required with
ondelete='set null'

Fixes #25078

closes odoo/odoo#30617
2019-02-01 09:56:30 +00:00
Christophe Simonis 83cc046e9a [MERGE] forward port branch 11.0 up to 4c93e4be0d 2019-01-16 14:26:14 +01:00
Nicolas Martinelli b876cb397d [FIX] website: null type redirection
Commit 68e9d5504c makes the redirection type mandatory, which is
logical. Since we can't add such a constraint in stable, we make the
field required in the view and assign a default value (in case the
module is not upgraded, which is very likely to be the case).

opw-1924983

closes odoo/odoo#30252
2019-01-16 07:51:53 +00:00
Nicolas Lempereur 2a89f0c7f8 [REV] "[FIX] website: language prefixed URL on website"
This reverts commit 5324284f56
This reverts commit ad826f56ba.

If for example we had in a template:

 <script type="text/javascript" src="/payment_stripe/static/src/js/stripe.js"></script>

it has been reproduced to be gotten as:

 <script type="text/javascript" src="/de_DE/payment_stripe/static/src/js/stripe.js"></script>

which is unexpected and could cause an error.
closes #32090

Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-03-25 10:53:25 +00:00
Nicolas Lempereur 5324284f56 [FIX] website: language prefixed URL on website
In 10.0 and before, if we were eg. on website page /fr_FR/contact, if
`fr_FR` language (french) is installed and not the default website
language we would have all URL towards translated content (route with
multilang=True) prefixed with /fr_FR/ (the language code).

With 9cd982bcc some improvments were done to CDN but this also breaks
language prefixing, so this cause an unecessary redirect:

- we are on /fr_FR/contact and click on "Shop"
- we go to /shop
- odoo redirects US /fr_FR/shop

With this PR, URLs are prefixed with language once again.

note: the added test is hackish but the function tested depends on a lot
of odoo.http things that are hard to use for test (request.render,
request.context, request.httpreqest).

opw-1922051
closes #31792

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-22 16:14:09 +00:00
Denis Ledoux 611eea839c [FIX] website: don't change public user of website when saving general settings
Before this revision, the public user of your website could be changed
upon saving the general settings if you added users in the public group.

Case:
- Install website
- Add a user in the "public" group,
with a login sorted alphabetically before "public", let's say "1public"
- Open the general settings and save directly
- Notice the public user of the website has been changed to "1public",
and it did not keep "public", while you haven't changed anything
in the settings.

That said, the current heuristic to find the public user of a company
might not be the best, as you could automatically find users in the group
public that you would not like to use as the public user of your website.

In master, maybe a field `public_user_id` could be added on
`res.company`, and the `user_id` of the website could become
a related of the company public user.
In addition, when `_get_public_user` creates a new public user,
it could link it to the company in `public_user_id` field.

closes odoo/odoo#33332

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-05-13 12:25:56 +00:00
Nicolas Martinelli 77c708c516 [FIX] website: sign-up in multi-website
- Create 2 companies A & B
- For each company, create a website linked to a different URL and
  activate 'Free sign up' and 'Specific User Account'.
- As a public user, go to website of company B
- Go to 'Sign in > Don't have an account?' and create an account

The user is created in company A (the company of the user template)
instead of company B (the company of the website).

We set the company of the user based on the company of the website.

opw-1962197

closes odoo/odoo#32823

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-04-19 08:54:22 +00:00
Christophe Simonis fef49061ea [MERGE] forward port branch saas-11.3 up to 4c61621efb 2019-04-08 19:52:29 +02:00
Romain Derie a5a5a57e48 [FIX] website(_sale): allow to use and access website pricelist
Before this commit, if the website's company was different than the user
company, the ecommerce would use the user's company instead of its own
pricelists.

Step to reproduce:
  - Set company2 to website1
  - Create a pricelist1 for company1 and a pricelist2 for company2
  - With an user from company1, visit the website1.
  - The pricelist used will be the one from the user, pricelist1 and not the
    pricelist2 from company2 which is the website1 company.
2019-03-14 10:28:02 +00:00
Romain Derie 25a8b507b1 [FIX] website, website_sale: create utility method to check if frontend
Before this commit, at multiple places to check if we were in a frontend
context we would check if `request and hasattr(request, 'website')` and
then access `request.website`.

Now, we call an utility method to get that website if we are in a frontend
context. If not the method will return False.

This method will be usefull for incoming pricelist fixes & tests.
Indeed, we will have more check of that kind and this will be easier to mock as
mocking this method will be enough, instead of mocking every method doing that
if condition to simulate a frontend context (to do website tests in python
wihout having to go frontend with a tour).
2019-03-14 10:28:02 +00:00
Romain Derie 63ba2317f8 [FIX] website: get the error view without parsing the view tree
Before this commit:
The `if` condition doing a `View._views_get` was supposed to be a sort of
'hack' for when the error occured in a child view (as the template raised would
be the parent, not the broken child).
But since we refactored that part to use etree, it was actually going into that
condition for every error even if the error was in the called template.
Proof is, we only set `editable` in that if condition, meaning going in the
else would actually prevent to show reset template.

Indeed the following code would always be true:
   et = etree.fromstring(view.with_context(inherit_branding=False).read_combined(['arch'])['arch'])
   node = et.find(exception.path.replace('/templates/t/', './'))
as read_combined returns all the view hierarchy DOM

Note: We could not fix this by checking exception.path against `arch` as we
could have false positive (eg the child view replace the <p> element by another
<p> element which is broken, then the path would be found in the parent view
even if the error was in the child view).

closes odoo/odoo#31515

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-03-07 10:30:54 +00:00
Romain Derie 3f5a6f423d [FIX] website: fix install theme error
Commit 5a81d8883 fixed the COW view deletion on module update but introduced an
error when installing a theme.

Indeed, when installing a theme, the first step is to remove the currently
installed theme from the website (by unlinking its ir.ui.view).

Commit 5a81d8883 introduced the fact that deleting an ir.ui.view during a
module uninstall also search and delete the COW views, calling
`_get_specific_views` (that expects a singleton).

When installing a theme, it calls `_theme_cleanup` which search COW views and
unlink them. If not cow view, unlink is called with an empty record set raising
the singleton error.

closes odoo/odoo#31662

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-03-07 13:36:10 +00:00
Romain Derie 5a81d88837 [FIX] website: delete cow view on module update
Before this commit, when a view was removed during a module update (eg: the
record was deleted from the file), its COW views would not be deleted.

This could lead to unwanted behaviors including tracebacks(1).

This commit is somehow related/an extension of b5fe23055d that handle COW view
write during module update and 2e32cc5aa3 that remove COW views during module
uninstall.

task-1931683

Note: Some existing tests had to be run post install

(1) A view doing a t-call is COW'd, then that view and its t-called view are
    removed. If the cow view is not removed, the t-call will crash (see tests
    in this commit for detailed case).

closes odoo/odoo#31295

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-03-05 11:04:52 +00:00
Christophe Simonis 15f686eef6 [MERGE] forward port branch 11.0 up to 468dab6748 2018-11-15 20:39:10 +01:00
Sanjay Jamod 8f99013d01 [FIX] website: method should be called with action not with self
to avoid 'Expected singleton error'

OPW: 1909205

closes odoo/odoo#28648
2018-11-14 06:32:40 +00:00
Jeremy Kersten 96dc825c8c [FIX] website: reset template
fix retro compatibilty

Old qweb template http_error_debug was wrong, but we never entry in the if.
Now that we fixed to enter in the if, we need to make retrocompatible code to
be able to display the QWebException from v9 with the old view from v8.

odoo.exceptions.QWebException
  vs
odoo.addons.base.models.qweb.QWebException

closes odoo/odoo#31383
2019-02-14 13:39:55 +00:00
Jeremy Kersten 8eb1abf760 [FIX] website: reset template
Create new env with current user instead of admin.
Avoid to show odoo bot as connected into the exceptions pages.
2019-02-14 12:15:48 +01:00
Romain Derie"Romain Derie <rde@odoo.com>""Jérémy Kersten <jke@openerp.com>"
ef03db9edd [FIX] website: restore reset_templates functionality
Since AST was introduced to compile Qweb templates, the reset templates
functionality is not working anymore.
Actually, it does not even appear anymore as the conditions to trigger and show
the reset view behavior can't be True anymore.
Indeed, the code is still importing the old QWebException from odoo.exceptions
which is now just an empty class.
The QWebException that should now be used is the one from odoo.base.models.qweb

More than just a wrong import, the QWebException properties have completely
changed.

Since its last working version (Odoo 9.0), a lot of changes occured, mostly:
  - Odoo 11.0: new model website.page, which completely changed the pages
    behavior and changed the models.
  - Odoo 12.0: multi-website, which introduced the Copy On Write (COW) that
    redefined how we write on view in a website context. We now need to reset
    copied/specific views that have no model_data_id.

This fix is for a stable version. There is some flows that can't be fixed
without a refactoring or new fields (mainly because of the arch_fs being
erased when writing on `arch`, plus we can't introduce a module reload in
stable).
The goal of this commit is to fix the basic and standard case of broken views,
which is when non-technical users are breaking the views through HTML editor.

To reset the views, we will read the original arch in the XML file, as the
dev mode is doing.
To be eligible for the reset, the broken view need an `arch_fs` set. If the
view arch has been modified anywhere else than the frontend, the `arch_fs`
will be erased and the view wont be able to be reset.
As the broken views will be specific views, we will simply read the generic
view in the XML file and write it on the specific. We can't simply remove the
specific view as we might be on a specific tree.

Specific case, in case of custom views create dropping a snippet in an oe_struc
we just delete this inehrited view to allow end user to have their page back.

In some case of bad compilation in sub template, we try to guess which inherited
view, t-called view is broken by string matching based on 'last_path_node' xpath.

Add new module test_website to add tests, it will be usefull for futur test of
install/uninstall and ...

Todo in master:
  - try to track on QWebException the real template that is broken and not only
    the last node from the main template.

Co-authored-by: "Romain Derie <rde@odoo.com>"
Co-authored-by: "Jérémy Kersten <jke@openerp.com>"

closes odoo/odoo#29957
2019-02-13 20:33:18 +00:00
Romain Derie 01d925e052 [FIX] website: don't flag generic view as noupdate when COWing
Once `website` module is installed, the `save` method will always write on the
specific view or create it if it does not exist yet.
This means that actually, the generic view will never have his `arch` modified
through the `save` method.
Thus, there is no need to flag it as noupdate as we want to receive update for
that view (that might be used by other website without a specific view).
2019-02-12 15:48:24 +00:00
Sébastien Theys 4a202440b8 [FIX] website: allow scheme and port on domain (multi-website)
Before this commit, the website selection was not working when a scheme or port
was encoded in the domain field. This was not obvious or natural for the user,
because the easiest way to fill it was to copy/paste the URL from the browser.

Now it works when scheme or port are encoded, it is even strongly recommended to
actually encode them if they don't take a default value because they will be
used when creating full URL to the website (typically when sending emails to
clients where a link back is necessary).

PR: #30000
2019-02-06 09:50:42 +00:00
Sébastien Theys c1be1993f9 [FIX] *: share URL on the correct website if possible
* = base, auth_signup, mail, portal, sale, website, website_sale

Before this commit, sending an object by email would always link to web.base.url
even if the object was created from a specific website.

Now if the object has a website, we use the URL of that website if it is set.
The fallback will always be on the web.base.url.

opw-1921030
PR: #30000
2019-02-06 09:50:38 +00:00
Jeremy Kersten bb473003d7 [FIX] website: res_config_setting in multi company
Before this commit, if the first website in the select was not in your current
company, it raises a traceback.

Now with filter on your own company, and support empty website selected
removing required on related field and using attrs dynamic to make it required

closes odoo/odoo#30769
2019-02-01 09:34:06 +00:00
Jeremy Kersten 9cfd1eefd8 [FIX] website: don't copy is_published
Before this commit, if you duplicate a published record on the website,
the copy was already published, while in most of case you need to update
it to adapt to the new content. There doesn't make senses to duplicate the
same content on a website and let the duplicate content.

Task-1930058
2019-01-22 16:38:48 +00:00
Christophe Simonis d657d6457f [FIX] website: update *all* views, not only website ones
closes odoo/odoo#30369
2019-01-18 16:34:08 +00:00
Romain Derie b5fe23055d [FIX] website: handle COW'd views during module install/update
Since multi-website, we COW (copy on write) views when editing a view on a
website.
This is causing 2 issues related to module install/update:
1. During a module install, when creating an inherited view, it will create
   that view as expected on the generic tree.
   But that generic tree may not be used on website(s). Indeed, if the view
   was edited, we are now using a copy of the view instead of the original
   XML view (with an xml_id).
   That copied view won't get the new inherited view in its view tree.
   Now, we correctly copy the new view under every specific view tree (if
   exists).
2. During a module update, when updating a view, it will only update the view
   having the xml_id, so the generic one.
   But most of the time, the generic view is not used as it was usually COW'd
   and the specific view now replace the generic one.
   Now, we also apply the update on the COW'd view. Note that only unmodified
   field will be updated, this behavior basically mimic the noupdate behavior
   on view's ir.model.data.

Step to reproduce for bug 1:
  - Install website_sale module
  - Go to a product page and then enter edit mode
  - Make a modification to trigger COW, eg edit the information area under the
    price "30-day money-back guarantee".
  - Now install website_sale_comparison module
  - The product page won't have the comparison button as the comparison view
    inheriting the product view was created on the generic tree and not copied
    on the specific tree (COW'd before the comparison module install).

Step to reproduce for bug 2:
  - Repeat first 3 steps of bug 1
  - Now make a modification in a view from the XML file in
    website_sale_comparison module and update the module
  - Only the view with the xml_id is updated, not it's COW'd views. This mean
    that only the generic view is updated and not the specific one(s) really
    used on the website.

task-1920487

closes odoo/odoo#29956
2019-01-10 16:19:35 +00:00
Romain Derie 20e9d77be8 [FIX] website: correct order when copying view children on COW
Before this commit, a generic view tree could be valid but impossible to copy
on a COW specific tree.

This was because when looping through inherit_children_ids to copy them, they
would be sorted by the ir.ui.view sort order (name, priority, id).
Indeed, when applying view inheritance and reading a view arch, children are
sorted by (priority, id).

Thus, if sorting the children by (name, priority, id) was different than
sorting by (priority, id) and the children view would conflict in that new
order, the COW would raise an error "can't find DOM element"

Step to reproduce:
  - Create a parent view with just a DIV in arch
  - Add a child view that add something inside that DIV
  - Add another child view with a name alphabetically lower than the other
    child and that replace the DIV by something else, like a SECTION
  - Everything works as expected, when reading the parent view arch, the first
    child is inserting something into the DIV and then the second is replacing
    the DIV
  - Now try to trigger the COW on the parent view by writing something on it in
    a website context
  - It will crash as the child views will be copied in another order, sorted
    firstly by name.
  - Indeed, when reading parent view, the second child will be copied first as
    it's name is lower than the first, it will then replace the DIV by a SPAN.
    When trying to copy the other child view that is supposed to insert
    something into the DIV, the DIV will not be found and it will crash.
2019-01-09 13:09:26 +00:00
Christophe Simonis 378b283c02 [MERGE] forward port branch saas-11.3 up to 83cc046e9a 2019-01-16 17:02:34 +01:00
Sébastien Theys 6b85cbc844 [FIX] website: fix viewref to not raise when raise_if_not_found=False
`ref` could raise even if raise_if_not_found was False on `viewref`, now we
prevent that, and rely only on the exception on `viewref`.

Also, when not set to raise, the method could return None instead of a recorset.

PR: #29753
2019-01-09 12:54:46 +00:00
Sébastien Theys 9ba8dedbf5 [FIX] base,website: make better comments for view helpers
PR: #29753
2019-01-09 12:51:56 +00:00
Nans Lefebvre 8c5ec851fc [FIX] website: fix menus unlinking
Fine-tuning of commit b48d2b6b5e.
The call to unlink inside the unlink can recurse infinitely
in case there is a copy of a menu.
We replace that direct call by an accumulator so no recursion occurs.

opw 1922448

closes odoo/odoo#30032
2019-01-09 10:29:52 +00:00
Atul Patel c5cb1a6b38 [FIX] website: remove faulty decorator
copy_menu_hierarchy is not a model function since it expects
to iterate on a recordset of websites

closes odoo/odoo#29723
2018-12-24 18:05:51 +00:00
Romain Derie 88242d6a15 [FIX] website: simplify filter_duplicate
The `filter_duplicate()` method was introduced with b0b6b9afb5 for
website_version.
The module was removed on Odoo 12.0 with https://github.com/odoo/enterprise/commit/51c1bb3cca9ae02fc55cb49ba98cec2901a8e273

`filter_duplicate()` can now fit the multi-website behavior more simply.

Closes #29347
2018-12-19 18:24:50 +00:00
Romain Derie ae8232136d [FIX] website: get only specific view children on _views_get()
Before this comit:
The `_views_get()` method would be called recursively for every
`inherit_children_ids`.
At the end of the method, we would get the complete view hierarchy, including
duplicate hierarchies for website specific copies (COW).

Then, the `get_related_views` that is calling `_views_get()` would be overriden
in website module to keep only most specific views.

But this would not be enough as it would leave orphans from other trees:
  - Have a base view 'B'
  - That has an inherited view 'I'
  - That has itself an inherited view 'II'
  - Now make the hierarchy specific on a website from 'I'
  - And add another inherited view to 'I' on the generic tree
This become:
              B
             / \
            /   \
           I     I'
          / \     |
        II  II2   II'

As explained, filtering duplicates would not be enough as it would correctly
remove 'I' and 'II' from the generic tree but would not remove 'II2'.

At the end, it would return "B", "II2", "I'" and "II'".

Now, we correctly return only "B", "I'" and "II'" by ignoring generic trees
when there is a specific one.

Closes #29347
2018-12-19 18:24:53 +00:00
Romain Derie f7df35540b [FIX] web_editor, website(_theme_install): avoid theme.ir.ui.view crash
In a particular case, `_views_get` was mixing apples and oranges, ir.ui.view
and theme.ir.ui.view.

This was the case if a theme has a theme.ir.ui.view t-calling another
theme.ir.ui.view.
(Only theme's sale bridge cause this issue, eg theme_kea_sale.products)
Then, having that theme installed on a website would make all other website
without that theme to crash when opening the /shop customize menu.

Indeed, the theme.ir.ui.view would have the xml_id theme_kea_sale.search.
The generic view `website_sale.products` would have `theme_kea_sale.products`
as inherit child which is website specific and t-call `theme_kea_sale.search`.

Then, on a website witout theme_kea installed, opening the customize menu would
call `get_related_views` that would call `_views_get` that would loop through
inherit children calling `_view_obj` that would not find a view with that key
and would fallback on self.env.ref, finding the theme.ir.ui.view.

Note: `_views_get` might return specific view for another website but that will
      be filtered on `get_related_views` override in website.

Step to reproduce:
  - Have at least 2 websites and website_sale installed
  - Install theme_kea on a website, it will also install theme_kea_sale
  - Go on the website that has not theme_kea installed
  - Go to /shop
  - Open Customize menu, it won't load because of python crash

opw-1914576
Closes #29347
2018-12-19 18:23:36 +00:00
Romain Derie 9c4eab3ef4 [FIX] website: ensure only editor can force website with URL 'fw'
Before this commit, everyone could use the `fw` query string to force a
website during the dispatching. Plus, it would not require multi-website to be
enabled (multi-website only display UI elements, it does not affect behaviors
as they are already triggered even if multi-website is disabled).

This was intended but caused an issue for public users.
Indeed, the code that would force a website during the http dispatching would
be executed in `_add_dispatch_parameters`, after the auth methods.

Then, the request.uid would be the one from the website we were leaving and not
the one of the website we are forcing.
Public user would then not be recognized as such (if both websites have their
own public user) and would have interface glitchs (considered as connected).
Note: Next reload or page navigation would set the request.uid correctly.

Now:
To avoid such a behavior, we decided to allow only designer user to be able to
switch website with the `fw` query string, and only if multi-website is
enabled.
Note: The designer group check is done on the leaving website and not the
      forcing one as `_add_dispatch_parameters` is executed after auth methods.
      There is no way to check with which user the user will be logged on the
      forcing website (Public, Same user, different user?).
      Also, it would have to handle the same domain/different domain.

Step to reproduce:
  - Activate multi-website
  - Activate multi-company
  - Create SiteA and SiteB
  - Create CompanyA and CompanyB
  - Set CompanyA on SiteA and CompanyB on SiteB
  - A new public user will be bootstraped for CompanyB
  - Optionnaly, setting manually a different public user for CompanyB will do
    the same.
  - Go to website 1, request.uid is PubUserA and request.website is SiteA
  - Navigate to website 2 with `?fw=2` in URL, request.uid will be PubUserA and
    request.website will be SiteB.
    This is wrong, request.uid should be PubUserB as we are on SiteB

This will result in multiple bug, mainly the non logged user will see the
dropdown in the navbar as if they were logged in showing 'PubUserA'.

Fixes #27998

closes odoo/odoo#29136
2018-12-12 14:21:53 +00:00
Christophe Simonis 21eb31d804 [MERGE] forward port branch 11.0 up to a587325ca7 2018-10-31 19:22:21 +01:00
Akim Juillerat b4ca8d0bc6 [FIX] website: Add onchange language_ids on website model
On res.config.settings for website, when removing a language from language_ids, if this language is defined as default_lang_id, the default language will be updated by an onchange to prevent any inconsistency.
The same should happen when doing this directly on the form view of a website record.

closes odoo/odoo#27727
2018-10-19 13:58:42 +00:00
Romain Derie a67553c9d2 [FIX] website_event: website menu on event not working
Commit 7077f18e3 tried to fix the website event menu issue.
But the fix was wrong and fixed only the event having a website_id set.
After the 7077f18e3 fix, event with a website_id set are working as expected
but the ones without a website_id are not working.
Indeed, it will create a website.menu without a website_id which will result in
the menu being duplicated for each website (multi-website rule).
The required on website_id when activating website menu on event was trying to
hide that new issue but it was problematic since:
1. We were removing a feature for no reason as it would not be possible anymore
   to create a generic event (no website) with website menu activated.
2. The required would only work in form view, demo data or custo data loaded
   through xml without a website_id but having website menu activated would
   still bug and would not have a menu. Worst, the menu would be duplicated for
   every website and added to the website navbar.

Now, regardless of the event having a website_id set or not, activating or
deactivating event menu will work.

closes odoo/odoo#29036
2018-11-26 15:04:57 +00:00