New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] *: share URL on the correct website if possible #30000

Open
wants to merge 3 commits into
base: 12.0
from

Conversation

Projects
None yet
5 participants
@seb-odoo
Copy link
Contributor

seb-odoo commented Jan 7, 2019

rebase ff

opw-1921030

@seb-odoo seb-odoo self-assigned this Jan 7, 2019

@robodoo robodoo added the seen 🙂 label Jan 7, 2019

@seb-odoo

This comment was marked as resolved.

Copy link
Contributor

seb-odoo commented Jan 7, 2019

TODO need to write tests
and probably replace all other self.env['ir.config_parameter'].sudo().get_param('web.base.url')

@seb-odoo

This comment has been minimized.

Copy link
Contributor

seb-odoo commented Jan 7, 2019

When ready, this PR can be merged standalone, but would work much better with the fixes on #29943 (to also apply here)

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from d289d23 to 1ecec43 Jan 7, 2019

@seb-odoo seb-odoo requested review from rdeodoo and JKE-be Jan 7, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch 3 times, most recently from e4b7214 to 5e792c3 Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[FIX] website: allow scheme and port on domain (multi-website)
Before this commit, the website selection was not working when a scheme was
encoded in the domain field.

Moreover, the port was ignored, which caused issues in the generated links if
the port was needed.

Now, it is strongly recommended to encode both the scheme and the port, because
they will be used when creating full link to the website (typically when sending
emails to clients where a link back is necessary).

PR: odoo#30000

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from 5e792c3 to a66d595 Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[FIX] website: allow scheme and port on domain (multi-website)
Before this commit, the website selection was not working when a scheme was
encoded in the domain field.

Moreover, the port was ignored, which caused issues in the generated links if
the port was needed.

Now, it is strongly recommended to encode both the scheme and the port, because
they will be used when creating full link to the website (typically when sending
emails to clients where a link back is necessary).

PR: odoo#30000

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from a66d595 to e377bfd Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[FIX] website: allow scheme and port on domain (multi-website)
Before this commit, the website selection was not working when a scheme was
encoded in the domain field.

Moreover, the port was ignored, which caused issues in the generated links if
the port was needed.

Now, it is strongly recommended to encode both the scheme and the port, because
they will be used when creating full link to the website (typically when sending
emails to clients where a link back is necessary).

PR: odoo#30000

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from e377bfd to e64d209 Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[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 both if they don't use a default value because they will be
used when creating full link to the website (typically when sending emails to
clients where a link back is necessary).

PR: odoo#30000

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from e64d209 to 00c1e07 Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[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 both if they don't use a default value because they will be
used when creating full link to the website (typically when sending emails to
clients where a link back is necessary).

PR: odoo#30000

@robodoo robodoo added the CI 🤖 label Jan 8, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from 00c1e07 to f7f758c Jan 8, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[FIX] sale,sale_management: prevent traceback on get_access_action
The field `sale_order_template_id` is only defined on `sale_management`, so
calling that method without `sale_management` would crash (traceback).

The method was in `sale_management` in the first place but commit
34c47ee happened and some mistakes were made
that day.

PR: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[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 another company or another website.

Now, we try to guess which URL is the most appropriate: if the object has a
website, we use the URL of that website if it is set. If the object has a
company and the company has at least one website, we use the URL of the first
website found for that company.

For Invoice and SO: take the URL from the website if set, or from the company.

For auth: take the URL from the company of the user.

If the URL can't be guessed from the object itself, we try to look for the best
URL for the current company of the current user.

The fallback will always be on the web.base.url.

opw-1921030
PR: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 8, 2019

[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 both if they don't use a default value because they will be
used when creating full link to the website (typically when sending emails to
clients where a link back is necessary).

PR: odoo#30000

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Jan 8, 2019

JKE-be added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2019

[FIX] tests: fix chrome headless to work with any local HOST
Before this commit, changing the value of the HOST variable didn't work because
it wasn't correctly used everywhere.

Moreover, the `web.base.url` was not correctly set: it is set during
authenticate, but when calling it from the console instead of from a request,
which is the case for tests, it is not able to grab and set the URL as needed.

PR: odoo#30000

JKE-be added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2019

[FIX] sale,sale_management: prevent traceback on get_access_action
The field `sale_order_template_id` is only defined on `sale_management`, so
calling that method without `sale_management` would crash (traceback).

The method was in `sale_management` in the first place but commit
34c47ee happened and some mistakes were made
that day.

PR: odoo#30000

JKE-be added a commit to odoo-dev/odoo that referenced this pull request Jan 17, 2019

[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: odoo#30000

robodoo pushed a commit that referenced this pull request Jan 17, 2019

[FIX] tests: fix chrome headless to work with any local HOST
Before this commit, changing the value of the HOST variable didn't work because
it wasn't correctly used everywhere.

Moreover, the `web.base.url` was not correctly set: it is set during
authenticate, but when calling it from the console instead of from a request,
which is the case for tests, it is not able to grab and set the URL as needed.

PR: #30000

robodoo pushed a commit that referenced this pull request Jan 17, 2019

[FIX] sale,sale_management: prevent traceback on get_access_action
The field `sale_order_template_id` is only defined on `sale_management`, so
calling that method without `sale_management` would crash (traceback).

The method was in `sale_management` in the first place but commit
34c47ee happened and some mistakes were made
that day.

PR: #30000

closes #30294
[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

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from b1b074c to 7716f45 Jan 18, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[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: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: odoo#30000

@robodoo robodoo removed the CI 🤖 label Jan 18, 2019

@seb-odoo

This comment has been minimized.

Copy link
Contributor

seb-odoo commented Jan 18, 2019

The 2 first commits have been merged separately (see commit referenced by robodoo above).

Now I'm rebasing it and making my final own review.

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from 7716f45 to 1dcc207 Jan 18, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[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: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: odoo#30000
@seb-odoo

This comment has been minimized.

Copy link
Contributor

seb-odoo commented Jan 18, 2019

Remaining points to discuss before review/merge:

  • Do we actively try to match the correct port and/or scheme when selecting website based on domain? They can (or have to be) encoded in the field, but they are currently not used in the detection, just when creating links.
  • get_base_url is currently redefined in several models because it is not a mixin (website_id specified separately on each of those models). We merge it this way in 12.0?
@JKE-be

This comment has been minimized.

Copy link
Contributor

JKE-be commented Jan 18, 2019

  1. if you can handle it in less than 2 lines (heu, yes so 1 line) in the filter yes.
  2. no mixin in 12, maybe in master laterw e could reuse website mixin.

Probably on website helper that return (http_domain, domain) -> (scheme+(name+tld)+port, name+tld)

@robodoo robodoo added the CI 🤖 label Jan 18, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from 1dcc207 to a80eb9e Jan 18, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[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: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: odoo#30000

@robodoo robodoo removed the CI 🤖 label Jan 18, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from a80eb9e to 9323a89 Jan 18, 2019

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[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: odoo#30000

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Jan 18, 2019

[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: odoo#30000

seb-odoo added some commits Jan 14, 2019

[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
[FIX] website_sale: correctly set access token for cart recovery
The access token is automatically generated when calling `_get_share_url` but
for the cart recovery we don't use that standard method because we need to send
the user to a specific route, so we need to generate the access token manually.

Without this fix, the user will receive the link with access_token=False which
would lead to a 404 page.

Also added a test for the cart recovery flow.

PR: #30000

@seb-odoo seb-odoo force-pushed the odoo-dev:12.0-sales-share-seb branch from 9323a89 to 6391a5c Jan 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment