From 530546a3e39fb5988bbdc178ad56ee74c3c45e08 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 23 May 2017 17:38:38 +0200 Subject: [PATCH] [FIX] point_of_sale: _confirm_orders To help users to know why they can't close their pos sessions when a Sales Journal is not set in the pos.config. opw:744758 --- addons/point_of_sale/i18n/point_of_sale.pot | 6 ++++++ addons/point_of_sale/models/pos_session.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/addons/point_of_sale/i18n/point_of_sale.pot b/addons/point_of_sale/i18n/point_of_sale.pot index 6c54bab5d64..99adf770938 100644 --- a/addons/point_of_sale/i18n/point_of_sale.pot +++ b/addons/point_of_sale/i18n/point_of_sale.pot @@ -3528,6 +3528,12 @@ msgid "You have to select a pricelist in the sale form !\n" "Please set one before choosing a product." msgstr "" +#. module: point_of_sale +#: code:addons/point_of_sale/models/pos_session.py:24 +#, python-format +msgid "You have to set a Sale Journal for the POS:%s" +msgstr "" + #. module: point_of_sale #: model:ir.actions.act_window,help:point_of_sale.product_product_action msgid "You must define a product for everything you sell through\n" diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index d60767f26da..d914f3d82cf 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -20,6 +20,8 @@ class PosSession(models.Model): orders = session.order_ids.filtered(lambda order: order.state == 'paid') journal_id = self.env['ir.config_parameter'].sudo().get_param( 'pos.closing.journal_id_%s' % company_id, default=session.config_id.journal_id.id) + if not journal_id: + raise UserError(_("You have to set a Sale Journal for the POS:%s") % (session.config_id.name,)) move = self.env['pos.order'].with_context(force_company=company_id)._create_account_move(session.start_at, session.name, int(journal_id), company_id) orders.with_context(force_company=company_id)._create_account_move_line(session, move)