From 31f8af459814bd9f161bcfa406de534f7ebf2d7d Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 8 Oct 2020 12:12:41 +0000 Subject: [PATCH] [FIX] point_of_sale: check session in right company - Create companies A & B - Switch to company B - Open a POS session in company B, but do not close it - Switch to company A - Set a Lock Date for Non-Advisers The error message 'Please close all the point of sale sessions...' is raised. The message shouldn't be raised since the session is not in the company we are setting a lock date. We filter the session based on the company. opw-2351930 closes odoo/odoo#59529 X-original-commit: a1445bf45fadf21a4af5dd2791efda4a4450a825 Signed-off-by: Nicolas Martinelli (nim) --- addons/point_of_sale/models/res_company.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/res_company.py b/addons/point_of_sale/models/res_company.py index 2b4b5917d82..56df65b945a 100644 --- a/addons/point_of_sale/models/res_company.py +++ b/addons/point_of_sale/models/res_company.py @@ -21,7 +21,17 @@ class ResCompany(models.Model): """ pos_session_model = self.env['pos.session'].sudo() for record in self: - sessions_in_period = pos_session_model.search([('state', '!=', 'closed'), '|', ('start_at', '<=', record.period_lock_date), ('start_at', '<=', record.fiscalyear_lock_date)]) + sessions_in_period = pos_session_model.search( + [ + "&", + "&", + ("company_id", "=", record.id), + ("state", "!=", "closed"), + "|", + ("start_at", "<=", record.period_lock_date), + ("start_at", "<=", record.fiscalyear_lock_date), + ] + ) if sessions_in_period: sessions_str = ', '.join(sessions_in_period.mapped('name')) raise ValidationError(_("Please close all the point of sale sessions in this period before closing it. Open sessions are: %s ") % (sessions_str))