You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
3.8 KiB
77 lines
3.8 KiB
# -*- coding: utf-8 -*-
|
|
#############################################################################
|
|
#
|
|
# Cybrosys Technologies Pvt. Ltd.
|
|
#
|
|
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
|
|
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
|
|
#
|
|
# You can modify it under the terms of the GNU LESSER
|
|
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
|
|
#
|
|
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
|
|
# (LGPL v3) along with this program.
|
|
# If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
#############################################################################
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class LoyaltyReward(models.Model):
|
|
"""To add a new reward type in loyalty reward"""
|
|
_inherit = 'loyalty.reward'
|
|
|
|
reward_type = fields.Selection(selection_add=[
|
|
('redemption', 'Redemption')
|
|
], ondelete={'redemption': 'set default'},
|
|
help="A new reward type is added")
|
|
redemption_point = fields.Integer(string='Redemption Point', default=1.0,
|
|
readonly=True,
|
|
help="No of points redeemed according "
|
|
"to the redemption amount")
|
|
redemption_amount = fields.Float(string='Maximum Redemption per Point',
|
|
default=1.00, required=True,
|
|
help="Maximum Redemption per redemption "
|
|
"point")
|
|
max_redemption_type = fields.Selection(
|
|
[('amount', 'Amount'), ('percent', 'Percentage'), ('points', 'Points')],
|
|
default="amount",
|
|
required=True,
|
|
help="Redemption type based on Fixed Amount,percentage or Point wise")
|
|
max_redemption_amount = fields.Float(string='Max Redemption Amount',
|
|
default=10, required=True,
|
|
help="Maximum redemption amount "
|
|
"given to an order")
|
|
redemption_frequency = fields.Integer(string='Redemption Frequency',
|
|
default=1, required=True,
|
|
help="Number of times this reward "
|
|
"can be claimed")
|
|
redemption_frequency_unit = fields.Selection([('day', 'Daily'),
|
|
('week', 'Weekly'),
|
|
('month', 'Monthly'),
|
|
('year', 'Yearly')],
|
|
default='day', required=True,
|
|
string='Redemption Frequency'
|
|
'Unit',
|
|
help="Choose the frequency "
|
|
"for claiming the reward")
|
|
redemption_eligibility = fields.Float(string="Redemption Eligibility",
|
|
default=200,
|
|
help="points required for claiming "
|
|
"the reward")
|
|
|
|
@api.model
|
|
def create(self, vals):
|
|
"""creation of new reward product"""
|
|
product = self.env['product.product'].create({
|
|
'name': vals['name'],
|
|
'detailed_type': 'service',
|
|
'available_in_pos': True,
|
|
})
|
|
vals['discount_product_id'] = product.id
|
|
return super(LoyaltyReward, self).create(vals)
|
|
|