From 0c97713ceb6615bfa9d5ee1f8da1e818b6c7bf7c Mon Sep 17 00:00:00 2001 From: rhe-odoo Date: Fri, 7 Oct 2022 10:10:43 +0000 Subject: [PATCH] [FIX] pos_loyalty: prevent gift card settings error. It was possible to sell gift cards without mail template or report link to the gift card program. Thus, it was impossible to get the info related to the card unless you have backend access rights. We now make sure the gift card program have a template and a report when starting the session. closes odoo/odoo#102885 X-original-commit: e81db2e6e1a3179f9cb6c8410111201d311a97ab Signed-off-by: Masereel Pierre --- addons/loyalty/data/loyalty_demo.xml | 1 + addons/pos_loyalty/data/pos_loyalty_demo.xml | 4 ++++ addons/pos_loyalty/models/pos_config.py | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/addons/loyalty/data/loyalty_demo.xml b/addons/loyalty/data/loyalty_demo.xml index e463796f3a8..ad32529f4cd 100644 --- a/addons/loyalty/data/loyalty_demo.xml +++ b/addons/loyalty/data/loyalty_demo.xml @@ -80,6 +80,7 @@ auto True $ + diff --git a/addons/pos_loyalty/data/pos_loyalty_demo.xml b/addons/pos_loyalty/data/pos_loyalty_demo.xml index a77d2c82149..7d430536343 100644 --- a/addons/pos_loyalty/data/pos_loyalty_demo.xml +++ b/addons/pos_loyalty/data/pos_loyalty_demo.xml @@ -90,4 +90,8 @@ + + + + diff --git a/addons/pos_loyalty/models/pos_config.py b/addons/pos_loyalty/models/pos_config.py index b25d948ba80..e4207ce34e6 100644 --- a/addons/pos_loyalty/models/pos_config.py +++ b/addons/pos_loyalty/models/pos_config.py @@ -63,6 +63,12 @@ class PosConfig(models.Model): reward = gc_program.reward_ids if reward.reward_type != 'discount' or reward.discount_mode != 'per_point' or reward.discount != 1: raise UserError(_('Invalid gift card program reward. Use 1 currency per point discount.')) + if self.gift_card_settings == "create_set": + if not gc_program.mail_template_id: + raise UserError(_('There is no email template on the gift card program and your pos is set to print them.')) + if not gc_program.pos_report_print_id: + raise UserError(_('There is no print report on the gift card program and your pos is set to print them.')) + return super()._check_before_creating_new_session() def use_coupon_code(self, code, creation_date, partner_id):