diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index d9c1e60844f..bb86e5d76c3 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -846,13 +846,13 @@ class PosOrder(models.Model): def _apply_invoice_payments(self): receivable_account = self.env["res.partner"]._find_accounting_partner(self.partner_id).with_company(self.company_id).property_account_receivable_id - payment_moves = self.payment_ids._create_payment_moves() + payment_moves = self.payment_ids.sudo().with_company(self.company_id)._create_payment_moves() invoice_receivable = self.account_move.line_ids.filtered(lambda line: line.account_id == receivable_account) # Reconcile the invoice to the created payment moves. # But not when the invoice's total amount is zero because it's already reconciled. if not invoice_receivable.reconciled and receivable_account.reconcile: payment_receivables = payment_moves.mapped('line_ids').filtered(lambda line: line.account_id == receivable_account) - (invoice_receivable | payment_receivables).reconcile() + (invoice_receivable | payment_receivables).sudo().with_company(self.company_id).reconcile() return payment_moves @api.model diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 951650a2c3f..b8108b77998 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -191,7 +191,7 @@ class PosSession(models.Model): "Cash Registers: %r", list(statement.name for statement in closed_statement_ids))) def _check_invoices_are_posted(self): - unposted_invoices = self.order_ids.account_move.filtered(lambda x: x.state != 'posted') + unposted_invoices = self.order_ids.sudo().with_company(self.company_id).account_move.filtered(lambda x: x.state != 'posted') if unposted_invoices: raise UserError(_('You cannot close the POS when invoices are not posted.\n' 'Invoices: %s') % str.join('\n',