Skip to content
Snippets Groups Projects
Commit ad5ac192 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] stock_account: return with limited access rights


- Create a SO, add a product with automated valuation
- Validate that SO
- Validate the picking
- Generate the invoice and validate
- As a limited user with only 'User' Inventory access rights, return the
  picking
- Validate the return

An `AccessError` is raised on `stock.valuation.layer`.

A regular user should be able to make a return, but not access the
accounting information. Therefore, use `sudo` where appropriate.

opw-2256074

closes odoo/odoo#51764

X-original-commit: c819a7e2
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 835dac49
Branches
Tags
No related merge requests found
......@@ -33,7 +33,7 @@ class StockMove(models.Model):
self.ensure_one()
price_unit = self.price_unit
# If the move is a return, use the original move's price unit.
if self.origin_returned_move_id and self.origin_returned_move_id.stock_valuation_layer_ids:
if self.origin_returned_move_id and self.origin_returned_move_id.sudo().stock_valuation_layer_ids:
price_unit = self.origin_returned_move_id.stock_valuation_layer_ids[-1].unit_cost
return not self.company_id.currency_id.is_zero(price_unit) and price_unit or self.product_id.standard_price
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment