[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 <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user