From 2db7d48d12ec2a4bb95708175cdb6b118c304c37 Mon Sep 17 00:00:00 2001 From: nie Date: Mon, 5 Oct 2020 08:51:08 +0000 Subject: [PATCH] [FIX] point_of_sale: unable to close open session with deleted journal Steps to reproduce the bug: - Create POS (P) - Create journal (J) and link it to (P) - Open a new session in (P) - Exit the session without closing it - Delete (J) Bug: You cannot close the session nor assign a new journal to the POS. opw:2347169 closes odoo/odoo#59097 X-original-commit: 636f1358e72e65a3210c95c60d1703c9cbd914dc Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: backspac --- addons/point_of_sale/models/pos_config.py | 3 ++- addons/point_of_sale/models/pos_order.py | 2 +- 2 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 99b30f6b38a..fde7cc69678 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -111,7 +111,8 @@ class PosConfig(models.Model): 'account.journal', string='Sales Journal', domain=[('type', '=', 'sale')], help="Accounting journal used to post sales entries.", - default=_default_sale_journal) + default=_default_sale_journal, + ondelete='restrict') invoice_journal_id = fields.Many2one( 'account.journal', string='Invoice Journal', domain=[('type', '=', 'sale')], diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 7b2157c68ba..8642bdd2f4c 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -246,7 +246,7 @@ class PosOrder(models.Model): note = fields.Text(string='Internal Notes') nb_print = fields.Integer(string='Number of Print', readonly=True, copy=False, default=0) pos_reference = fields.Char(string='Receipt Number', readonly=True, copy=False) - sale_journal = fields.Many2one('account.journal', related='session_id.config_id.journal_id', string='Sales Journal', store=True, readonly=True) + sale_journal = fields.Many2one('account.journal', related='session_id.config_id.journal_id', string='Sales Journal', store=True, readonly=True, ondelete='restrict') fiscal_position_id = fields.Many2one( comodel_name='account.fiscal.position', string='Fiscal Position', readonly=True,