From 2c4bcceb22114c6c41255209a63e4b910cfd813c Mon Sep 17 00:00:00 2001 From: Sylvain Francis Date: Fri, 23 Jul 2021 11:09:40 +0000 Subject: [PATCH] [FIX] point_of_sale: Don't fail when manually running scheduler When running the scheduler manually with a user who has no read access on pos.session (and point_of_sale is installed), the run fails silently for the user, and shows an error in the logs. "_alert_old_session" runs with the user's rights, who might have POS access. This commits runs the problematic search with sudo to work around this issue. closes odoo/odoo#74426 X-original-commit: 5ab9a317b1e0b3c1d5a143d49efb04b2f96c6300 Signed-off-by: pimodoo --- addons/point_of_sale/models/pos_session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index a3fedfe734c..02de2bc4a36 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -1145,7 +1145,7 @@ class PosSession(models.Model): def _alert_old_session(self): # If the session is open for more then one week, # log a next activity to close the session. - sessions = self.search([('start_at', '<=', (fields.datetime.now() - timedelta(days=7))), ('state', '!=', 'closed')]) + sessions = self.sudo().search([('start_at', '<=', (fields.datetime.now() - timedelta(days=7))), ('state', '!=', 'closed')]) for session in sessions: if self.env['mail.activity'].search_count([('res_id', '=', session.id), ('res_model', '=', 'pos.session')]) == 0: session.activity_schedule(