[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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-10-08 14:55:10 +00:00
parent a6644a7dd6
commit 31f8af4598
+11 -1
View File
@@ -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))