From f2477cf875b02a6e66b2cc6e4f309170141c058d Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Mon, 12 Aug 2019 08:20:08 +0000 Subject: [PATCH] [IMP] point_of_sale: avoid writing on pos config when session open When a session is opened on a POS config, we don't want to let users editing the pos config as modifying journals, payment method, pricelists,... Could lead to inconsistancies between what has been encoded on the pos orders and what are the available values on pos config. Before this commit, it wasn't taking into account the rescue sessions, only the normal ones. --- addons/point_of_sale/models/pos_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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()