From 4fad947c9f1659f77a1c3aa9112de2cb1b8dfdd6 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 24 Oct 2019 10:09:02 +0000 Subject: [PATCH] [FIX] point_of_sale: invoice validation - Create a user with rights 'Billing' only - Create an invoice, post An `AccessError` is raised. This is because the user has no access to the pos order. opw-2089587 closes odoo/odoo#39333 X-original-commit: d9d1f8099067e4de4891acbd6553c34eafff20a1 Signed-off-by: Nicolas Martinelli (nim) --- addons/point_of_sale/models/account_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/account_move.py b/addons/point_of_sale/models/account_move.py index db3857dc095..9097267a641 100644 --- a/addons/point_of_sale/models/account_move.py +++ b/addons/point_of_sale/models/account_move.py @@ -12,9 +12,9 @@ class AccountMove(models.Model): def _stock_account_get_last_step_stock_moves(self): stock_moves = super(AccountMove, self)._stock_account_get_last_step_stock_moves() for invoice in self.filtered(lambda x: x.type == 'out_invoice'): - stock_moves += invoice.mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'customer') + stock_moves += invoice.sudo().mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_dest_id.usage == 'customer') for invoice in self.filtered(lambda x: x.type == 'out_refund'): - stock_moves += invoice.mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') + stock_moves += invoice.sudo().mapped('pos_order_ids.picking_id.move_lines').filtered(lambda x: x.state == 'done' and x.location_id.usage == 'customer') return stock_moves class AccountMoveLine(models.Model):