diff --git a/addons/sale_stock/models/account_move.py b/addons/sale_stock/models/account_move.py index a21c5aebd79..1ebd6f8b52d 100644 --- a/addons/sale_stock/models/account_move.py +++ b/addons/sale_stock/models/account_move.py @@ -70,6 +70,9 @@ class AccountMove(models.Model): qties_per_lot[sml.lot_id] += qty_done for lot, qty in qties_per_lot.items(): + # access the lot as a superuser in order to avoid an error + # when a user prints an invoice without having the stock access + lot = lot.sudo() if float_is_zero(invoiced_qties[lot.product_id], precision_rounding=lot.product_uom_id.rounding) \ or float_compare(qty, 0, precision_rounding=lot.product_uom_id.rounding) <= 0: continue