[FIX] point_of_sale: random runbot error (20517)
When performing the picking action in the context of savepoint, the env
inside the action can randomly change causing an AccessError which is
caught as UserError (in the current point_of_sale code). Flushing before
calling a method in a savepoint will deterministically avoid this issue.
Note that the weakset used to store environments was modified in #121604
to avoid this kind of issue.
When using a cr.savepoint, the transaction must be flushed but in we
don't have any reference to the env that should be used on the cursor,
meaning that the env is chosen in the list of existing env. This choice
is random because Transaction.envs is using a Weakset.
In some case, the chosen env does not have the correct access right
because the context allowed_company_ids is corresponding to a company
coming from another test, leading to an access error, hidden by the try
except.
Flushing the environment before creating the savepoint will help to
prevent this issue by flushing on a well defined environment.
Note that the weakset used to store environments was modified in #121604
(master)
closes odoo/odoo#121659
Signed-off-by:
Xavier Dollé (xdo) <xdo@odoo.com>
Loading