Victor Feyens 6d99cf3eb6 [FIX] sale: access error on first pending payment
Steps to reproduce:

1) Install and enable the "Onsite" payment provider;
2) As a public user, add product(s) to your cart;
3) Try to pay with the "Onsite" provider.

-> Internal Server Error

Cause of the issue:

In the log, the cause of the issue is an AccessError,
specifying that we tried to read the field `transaction_ids`
on a `sale.order` without having the necessary access rights.

This shouldn't happen, since the payment & ecommerce flows
are executed in sudo mode, after making sure that the cart
belongs to the customer.

After investigation, pending payment transactions trigger
1) the sending of a mail to the customer
2) the first mail generation will request the report assets
3) the generation of the report assets will create an
   attachment and commit the transaction
4) committing the transaction will trigger a global
   flush of the environment, forcing the computation
   of pending mail wizard fields, with a different
   environment than the sudoed one initiating the sending
   of the mail.

This will lead to security errors as we try to access
`sale.order` fields content without having the rights
for it.

Standard fields being already in the cache, it will
be noticed when trying to read the `transaction_ids`
field.

Solution:

Manually prefetch the `transaction_ids` content with
the sudoed environment, since the records cache is
shared between the environments (until a more global
fix is found and deployed).

Introduced by #121376

opw-3628753

closes odoo/odoo#148199

X-original-commit: 511fe642b9860bd9d2f6b7ed728e7d3e6af48748
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2024-01-05 10:34:45 +00:00
2023-11-02 21:02:44 +00:00
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%