[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 <pim@odoo.com>
This commit is contained in:
rhe-odoo
2022-10-10 17:11:36 +02:00
parent 48b476f337
commit 0c97713ceb
3 changed files with 11 additions and 0 deletions
+1
View File
@@ -80,6 +80,7 @@
<field name="trigger">auto</field>
<field name="portal_visible">True</field>
<field name="portal_point_name">$</field>
<field name="mail_template_id" ref="loyalty.mail_template_gift_card"/>
</record>
<record id="gift_card_program_rule" model="loyalty.rule">
@@ -90,4 +90,8 @@
<field name="program_id" ref="pos_loyalty.loyalty_program"/>
</record>
<!-- Gift Cards -->
<record id="loyalty.gift_card_program" model="loyalty.program">
<field name="pos_report_print_id" ref="loyalty.report_gift_card"/>
</record>
</odoo>
+6
View File
@@ -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):