[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.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user