summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2021-04-13 08:33:17 +0000
committerWilliam Henrotin <whe@odoo.com>2021-04-13 09:00:34 +0000
commit7cd23a2cd464ccdfcb028b4f2c948654634b973c (patch)
treef09ccb11c519460a1ba23c45ae6aeb81aaa5c8ab /addons
parentd531e8a5e4d84fe6daa9110d076b0fc601a0b4d9 (diff)
[FIX] stock_account: get unit_cost in sudo mode
Commit ad5ac19218b4c529c651da951acdb93e1ac1227d adds a sudo() in the test condition but not inside the condition. Close #69144 closes odoo/odoo#69151 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/stock_account/models/stock_move.py2
-rw-r--r--addons/stock_account/tests/test_stockvaluation.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py
index 5b30e804a0e..4057e88a1dc 100644
--- a/addons/stock_account/models/stock_move.py
+++ b/addons/stock_account/models/stock_move.py
@@ -31,7 +31,7 @@ class StockMove(models.Model):
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.sudo().stock_valuation_layer_ids:
- price_unit = self.origin_returned_move_id.stock_valuation_layer_ids[-1].unit_cost
+ price_unit = self.origin_returned_move_id.sudo().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
@api.model
diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py
index e0b5332d2d7..2d0d6036eca 100644
--- a/addons/stock_account/tests/test_stockvaluation.py
+++ b/addons/stock_account/tests/test_stockvaluation.py
@@ -953,7 +953,7 @@ class TestStockValuation(SavepointCase):
stock_return_picking_action = stock_return_picking.create_returns()
return_pick = self.env['stock.picking'].browse(stock_return_picking_action['res_id'])
return_pick.move_lines[0].move_line_ids[0].qty_done = 1.0
- return_pick._action_done()
+ return_pick.with_user(self.inventory_user)._action_done()
self.assertEqual(self.product1.standard_price, 16)