oca-ocb-sale/odoo-bringout-oca-ocb-website_sale_loyalty/website_sale_loyalty/models/loyalty_program.py
Ernad Husremovic 73afc09215 19.0 vanilla
2026-03-09 09:32:12 +01:00

23 lines
944 B
Python

# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class LoyaltyProgram(models.Model):
_name = 'loyalty.program'
_inherit = ['loyalty.program', 'website.multi.mixin']
ecommerce_ok = fields.Boolean("Available on Website", default=True)
show_non_published_product_warning = fields.Boolean(compute='_compute_show_non_published_product_warning')
@api.depends('program_type', 'trigger_product_ids.website_published')
def _compute_show_non_published_product_warning(self):
for program in self:
program.show_non_published_product_warning = (
program.program_type == 'ewallet'
and any(not product.website_published for product in program.trigger_product_ids)
)
def action_program_share(self):
self.ensure_one()
return self.env['coupon.share'].create_share_action(program=self)