diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index ab1ef162bdd..a62c8334ff0 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -403,14 +403,15 @@ class PosConfig(models.Model): return pos_config def write(self, vals): + opened_session = self.mapped('session_ids').filtered(lambda s: s.state != 'closed') + if opened_session: + raise UserError(_('Unable to modify this PoS Configuration because there is an open PoS Session based on it.')) result = super(PosConfig, self).write(vals) config_display = self.filtered(lambda c: c.is_posbox and c.iface_customer_facing_display and not (c.customer_facing_display_html or '').strip()) if config_display: super(PosConfig, config_display).write({'customer_facing_display_html': self._compute_default_customer_html()}) - if self.current_session_id: - raise UserError(_('Unable to modify this PoS Configuration because there is an open PoS Session based on it.')) self.sudo()._set_fiscal_position() self.sudo()._check_modules_to_install()