Commit Graph
12 Commits
Author SHA1 Message Date
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
Xavier Morel 2eb007074c [IMP] website: mockify test
instead of using ad-hoc weirds

closes odoo/odoo#66682

X-original-commit: 7a42cc19492ada223678b6b67fc85fb121155e2b
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-02-23 12:18:07 +00:00
qsm-odoo 7c4922dcca [FIX] website: update python dailymotion regex
The regex was updated in JS with [1] but its python counterpart was
forgotten during forward-port.

[1]: https://github.com/odoo/odoo/pull/46898

closes odoo/odoo#65087

X-original-commit: 8d0b82683b95615267ff3acf84ebdd20456c595a
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-26 19:00:12 +00:00
Paul Morelle f463983cf9 [FIX] website: fix semantics of MockRequest
We should push the request object on the request stack only in the
__enter__ method, in order to be symmetrical with the __exit__ method.

closes odoo/odoo#53613

X-original-commit: 30e94d305f9cffa816ddc213e0b9329c0263c145
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Paul Morelle <madprog@users.noreply.github.com>
2020-06-24 16:06:11 +00:00
fja-odoo 7630ef3388 [IMP] website: add tests for website_visitor
website visitor testing had some flaws.

task-2079873

closes odoo/odoo#52281

X-original-commit: 4e5f049e48f06eb4be2a9972d06167e68bba1d61
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-06-02 16:08:43 +00:00
fja-odoo e33172e832 [IMP] website_sale, *: keep track of products viewed
*= website, website_livechat, website_rating

///// Tracking Product /////

Now when a user browse products in eCommerce, we keep track of the
products he looked at. We use the website_visitor
to store the products viewed. A cookie is added with a TTl of 30 min it
will prevent the RPC for that time. We track the page only if the
product view is tracked.

The recently viewed products are displayed as a snippet but also
with the customize option in product pages of website_sale.

Products that are in cart will not be returned as recently viewed.

It is possible to add a recently viewed product to the cart directly
from the carousel, it will not redirect to the cart. If we are on the
cart page, the product is displayed in the cart.

The Visitor page in website now references products viewed

///// Tracking Page /////

Feature to track a view was remove in: https://github.com/odoo/enterprise/pull/4834

That feature is now reintroduced and will use website_track instead of
leads to be stored.

The track field is now on the view instead of the page.

url field is added to website.track, it will store the url for pages and
views

The Visitor page in website now references urls viewed

Add some tests

task-1984575

closes odoo/odoo#35810

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-09-16 09:38:53 +00:00
Romain Derie 269aa59411 [IMP] http_routing, website: allow to customize the lang in URL
With this commit it is now possible to change the lang displayed in the URL.
Eg, you could use `/fr` instead of `/fr_BE`, or even a fancier `/french`.

Task-32838

Courtesy of pla@odoo.com

closes odoo/odoo#35135

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2019-08-26 16:35:19 +00:00
Martin Trigaux 1f5a4649a6 [MERGE] Forward port of saas-12.3 to saas-12.4 up to 87fc1554d6
closes odoo/odoo#34820

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-12 13:59:35 +00:00
Romain Derie 789aa140b9 [FIX] website, website_sale: correctly set company_id on address
During checkout, the user can create a new billing (only for public user as it
will create a 'normal' `res.partner`), a new shipping, edit its billing (that
will edit himself) or edit its shipping address.

All those cases will go through the exact same methods, public user and logged
in user included.

This previously led to multiple issues and multiple fixes to correctly set
`company_id` and `website_id` on the address (res.partner).

See 44372471ef that fixed the `website_id` part.

See 3a0f05f33 that fixed the multi-company behavior, but needed 2ba71140 to not
modify the company of an already created partner, but was still incomplete as
after that fix a logged in user would still have the admin (sudo) company
instead of the website one as supposed.

This commit will fix that bug and add some tests for all mentionned issues.

Related to #28853 as we want to backport the mentionned commit but needed to be
fix first.

closes odoo/odoo#34596

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-07-04 13:58:23 +00:00
Romain Derie 6ebcb1db80 [IMP] tool, website, website_sale: move test utils functions
We have multiple ways of simulating a frontend context while running python
tests (mainly during TransactionCase):
  - `MockObject` class from 8557bcfa30
  - `simulate_frontend_context` method from a5a5a57e48
  - `DotDict` from f8efc9a957

This commit moves `MockObject` to misc to be reusable and adapt it to be
accessible by dot notation with `DotDict`.

Part of #34396
2019-06-26 17:08:09 +00:00
Jeremy Kersten 8d64971e99 [FIX] website_sale: some quick fix related to odoo/odoo@1537b475b0
iframe autoclose failed
bad label for
typo

closes odoo/odoo#32740

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-04-16 15:27:32 +00:00
Dharmraj Jhala 33e17775e1 [ADD] website: added tools file for utility methods
This commit adds a new file 'tools.py' that can contain
utility methods which can be used at more than one places.

For now it contains a method 'get_video_embed_url', that
will accept a URL for the video and return an iframe snippet
that can be embedded if the provided URL is valid (returns
False otherwise).

task-1945483
2019-04-16 10:34:49 +00:00