summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Masereel <pim@odoo.com>2019-08-12 08:20:08 +0000
committerPierre Masereel <pim@odoo.com>2019-08-12 09:03:49 +0000
commitf2477cf875b02a6e66b2cc6e4f309170141c058d (patch)
tree5a6528bfce54f572e2e431659caffe0b75ccc777
parent98cc300cec732bced04bd5b4abbe9b87def10a91 (diff)
[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.
-rw-r--r--addons/point_of_sale/models/pos_config.py5
1 files 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()