@ -0,0 +1,45 @@ |
|||||
|
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
||||
|
:alt: License: LGPL-3 |
||||
|
|
||||
|
Advanced Loyalty Management |
||||
|
=========================== |
||||
|
In this module, we have incorporated new features such as deducting loyalty points upon refund, |
||||
|
converting change into loyalty points, displaying claimed rewards history, and introducing a new type of reward. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
* No additional configurations needed |
||||
|
|
||||
|
Company |
||||
|
------- |
||||
|
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Credits |
||||
|
------- |
||||
|
* Developer: (V17) NIHALA KP, Contact: odoo@cybrosys.com |
||||
|
|
||||
|
|
||||
|
Contacts |
||||
|
-------- |
||||
|
* Mail Contact : odoo@cybrosys.com |
||||
|
* Website : https://cybrosys.com |
||||
|
|
||||
|
Bug Tracker |
||||
|
----------- |
||||
|
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
||||
|
|
||||
|
Maintainer |
||||
|
========== |
||||
|
.. image:: https://cybrosys.com/images/logo.png |
||||
|
:target: https://cybrosys.com |
||||
|
|
||||
|
This module is maintained by Cybrosys Technologies. |
||||
|
|
||||
|
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
||||
|
|
||||
|
Further information |
||||
|
=================== |
||||
|
HTML Description: `<static/description/index.html>`__ |
||||
|
|
||||
|
|
@ -0,0 +1,22 @@ |
|||||
|
# -*- 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 . import models |
@ -0,0 +1,66 @@ |
|||||
|
# -*- 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/>. |
||||
|
# |
||||
|
############################################################################# |
||||
|
{ |
||||
|
'name': 'Advanced Loyalty Management', |
||||
|
'version': '17.0.1.0.0', |
||||
|
'category': 'Point of Sale', |
||||
|
'summary': 'Advanced loyalty Management', |
||||
|
'description': """When an order is refunded, any loyalty points gained from |
||||
|
that purchase are also revoked. This means that the points earned through |
||||
|
the refunded transaction will be deducted from the customer's loyalty |
||||
|
points balance.""", |
||||
|
'author': 'Cybrosys Techno Solutions', |
||||
|
'company': 'Cybrosys Techno Solutions', |
||||
|
'maintainer': 'Cybrosys Techno Solutions', |
||||
|
'website': "https://www.cybrosys.com", |
||||
|
'depends': ['pos_loyalty', 'sale'], |
||||
|
'data': [ |
||||
|
'views/loyalty_program_views.xml', |
||||
|
'views/loyalty_reward_rule_views.xml', |
||||
|
'views/res_partner_views.xml', |
||||
|
'views/pos_order_line_views.xml', |
||||
|
'views/loyalty_kanban_views.xml' |
||||
|
], |
||||
|
'assets': { |
||||
|
'point_of_sale._assets_pos': [ |
||||
|
'advanced_loyalty_management/static/src/xml/pos_loyalty_refund.xml', |
||||
|
'advanced_loyalty_management/static/src/js/pos_loyalty_deduction.js', |
||||
|
'advanced_loyalty_management/static/src/xml/pos_loyalty_receipt.xml', |
||||
|
'advanced_loyalty_management/static/src/js/pos_loyalty_deduction_receipt.js', |
||||
|
'advanced_loyalty_management/static/src/xml/pos_loyalty_change.xml', |
||||
|
'advanced_loyalty_management/static/src/js/pos_loyalty_change.js', |
||||
|
'advanced_loyalty_management/static/src/xml/pos_loyalty_popup.xml', |
||||
|
'advanced_loyalty_management/static/src/js/pos_loyalty_popups.js', |
||||
|
'advanced_loyalty_management/static/src/js/pos_reward_button.js', |
||||
|
'advanced_loyalty_management/static/src/xml/pos_redeem_reward_popup.xml', |
||||
|
'advanced_loyalty_management/static/src/js/pos_reward_redeem_popup.js', |
||||
|
'advanced_loyalty_management/static/src/js/pos_loyalty_card.js', |
||||
|
'advanced_loyalty_management/static/src/js/pos_payment_screen.js', |
||||
|
'advanced_loyalty_management/static/src/js/pos_ticketscreen.js', |
||||
|
], |
||||
|
}, |
||||
|
'images': ['static/description/banner.jpg'], |
||||
|
'license': 'LGPL-3', |
||||
|
'installable': True, |
||||
|
'auto_install': False, |
||||
|
'application': False, |
||||
|
} |
@ -0,0 +1,6 @@ |
|||||
|
## Module <advanced_loyalty_management> |
||||
|
|
||||
|
#### 08.04.2024 |
||||
|
#### Version 17.0.1.0.0 |
||||
|
#### ADD |
||||
|
- Initial Commit for Advanced Loyalty Management |
@ -0,0 +1,27 @@ |
|||||
|
# -*- 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 . import loyalty_program |
||||
|
from . import loyalty_reward |
||||
|
from . import pos_order_line |
||||
|
from . import pos_refund |
||||
|
from . import pos_session |
||||
|
from . import res_partner |
@ -0,0 +1,53 @@ |
|||||
|
# -*- 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, models, fields |
||||
|
|
||||
|
|
||||
|
class LoyaltyProgram(models.Model): |
||||
|
"""To set the point rate when change is converted to loyalty points""" |
||||
|
_inherit = 'loyalty.program' |
||||
|
|
||||
|
point_rate = fields.Integer(string='Point Rate', |
||||
|
help="Points corresponding to each unit", |
||||
|
default=1, required=True) |
||||
|
change_rate = fields.Monetary(string='Change Rate', default=1, |
||||
|
readonly=True, |
||||
|
help="Unit of money per points cost") |
||||
|
currency_id = fields.Many2one('res.currency', string='Currency', |
||||
|
default=lambda |
||||
|
self: self.env.user.company_id.currency_id, |
||||
|
help="Symbol of Currency") |
||||
|
|
||||
|
@api.model |
||||
|
def convert_loyalty(self, pid, cid, loyalty, partner_id): |
||||
|
"""converting the change to loyalty points""" |
||||
|
if int(cid[0]) < 0: |
||||
|
self.env['loyalty.card'].create({ |
||||
|
'program_id': pid[0], |
||||
|
'partner_id': partner_id[0], |
||||
|
'points': loyalty[0] |
||||
|
}) |
||||
|
|
||||
|
else: |
||||
|
loyalty_card = self.env['loyalty.card'].search( |
||||
|
[('id', '=', int(cid[0]))]) |
||||
|
loyalty_card.points += loyalty[0] |
@ -0,0 +1,78 @@ |
|||||
|
# -*- 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, models, fields |
||||
|
|
||||
|
|
||||
|
class LoyaltyReward(models.Model): |
||||
|
"""To create new reward type """ |
||||
|
_inherit = 'loyalty.reward' |
||||
|
|
||||
|
reward_type = fields.Selection(selection_add=[('redemption', 'Redemption')], |
||||
|
ondelete={'redemption': 'cascade'}, |
||||
|
help="Reward Type") |
||||
|
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.depends('reward_type', 'reward_product_id', 'discount_mode', |
||||
|
'discount', 'currency_id', 'discount_applicability', |
||||
|
'all_discount_product_ids') |
||||
|
def _compute_description(self): |
||||
|
"""compute description when the reward type is redemption""" |
||||
|
for reward in self: |
||||
|
if reward.reward_type == 'redemption': |
||||
|
reward.description = 'Redemption' |
||||
|
else: |
||||
|
res = super(LoyaltyReward, |
||||
|
self)._compute_description() |
||||
|
return res |
@ -0,0 +1,39 @@ |
|||||
|
# -*- 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, models, fields |
||||
|
|
||||
|
|
||||
|
class PosOrderLine(models.Model): |
||||
|
"""To Show the redeemed points in the redemption history""" |
||||
|
_inherit = 'pos.order.line' |
||||
|
|
||||
|
points_remaining = fields.Float(string="Points Remaining", |
||||
|
help="Remaining points after claming the " |
||||
|
"reward") |
||||
|
|
||||
|
@api.model |
||||
|
def remaining_points(self, balance, token): |
||||
|
"""Remaining points calculated after claiming the reward""" |
||||
|
order = self.env['pos.order'].search([('access_token', '=', token[0])]) |
||||
|
pos_order_line = self.env['pos.order.line'].search( |
||||
|
[('is_reward_line', '=', 'true'), ('order_id', '=', order.id)]) |
||||
|
pos_order_line.points_remaining = balance[0] |
@ -0,0 +1,82 @@ |
|||||
|
# -*- 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 models, fields |
||||
|
|
||||
|
|
||||
|
class PosOrder(models.Model): |
||||
|
"""To deduct the loyalty points when order is refunded""" |
||||
|
_inherit = 'pos.order' |
||||
|
|
||||
|
check = fields.Boolean() |
||||
|
|
||||
|
def _compute_order_name(self): |
||||
|
"""Compute the loyalty points when order is refunded""" |
||||
|
res = super()._compute_order_name() |
||||
|
partner_id = self.partner_id |
||||
|
li = [line.mapped('price_subtotal_incl') for line |
||||
|
in self.lines.filtered(lambda x: not x.is_reward_line)] |
||||
|
reward_line = self.refunded_order_ids.lines.filtered( |
||||
|
lambda x: x.is_reward_line) |
||||
|
points_cost = [] |
||||
|
for line in reward_line: |
||||
|
dict = {} |
||||
|
dict.update({ |
||||
|
line.coupon_id.id: line.points_cost |
||||
|
}) |
||||
|
points_cost.append(dict) |
||||
|
if self.refunded_order_ids: |
||||
|
cards = self.env['loyalty.card'].search( |
||||
|
[('partner_id', '=', partner_id.id)]) |
||||
|
|
||||
|
for program in cards: |
||||
|
if not self.refunded_order_ids.check: |
||||
|
for point in points_cost: |
||||
|
for key, values in point.items(): |
||||
|
if program.id == key: |
||||
|
program.points += point[key] |
||||
|
self.refunded_order_ids.check = True |
||||
|
|
||||
|
for rule in program.program_id.rule_ids: |
||||
|
if rule.reward_point_mode == 'money': |
||||
|
points_granted = rule.reward_point_amount |
||||
|
reward_points = [sum(sublist) * points_granted for |
||||
|
sublist in li] |
||||
|
program.points += reward_points[0] |
||||
|
elif rule.reward_point_mode == 'order': |
||||
|
reward_points = rule.reward_point_amount |
||||
|
reward_line_ids = len(reward_line) |
||||
|
ordered_qty = sum(self.refunded_order_ids.lines.mapped( |
||||
|
'qty')) - reward_line_ids |
||||
|
refunded_qty = sum( |
||||
|
self.refunded_order_ids.lines.filtered( |
||||
|
lambda x: not x.is_reward_line).mapped( |
||||
|
'refunded_qty')) |
||||
|
if ordered_qty == refunded_qty: |
||||
|
program.points -= reward_points |
||||
|
elif rule.reward_point_mode == 'unit': |
||||
|
points_granted = rule.reward_point_amount |
||||
|
qty = sum( |
||||
|
self.lines.filtered( |
||||
|
lambda x: not x.is_reward_line).mapped('qty')) |
||||
|
reward_points = qty * points_granted |
||||
|
program.points += reward_points |
||||
|
return res |
@ -0,0 +1,48 @@ |
|||||
|
# -*- 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 models |
||||
|
|
||||
|
|
||||
|
class PosSession(models.Model): |
||||
|
"""to load more fields in loyalty program and loyalty model""" |
||||
|
_inherit = 'pos.session' |
||||
|
|
||||
|
def _loader_params_loyalty_program(self): |
||||
|
"""To load more fields in the model loyalty.program""" |
||||
|
result = super()._loader_params_loyalty_program() |
||||
|
result['search_params']['fields'].extend(['point_rate', 'change_rate']) |
||||
|
return result |
||||
|
|
||||
|
def _loader_params_loyalty_reward(self): |
||||
|
"""to load more fields in the model loyalty.reward""" |
||||
|
result = super()._loader_params_loyalty_reward() |
||||
|
result['search_params']['fields'].extend( |
||||
|
['redemption_point', 'redemption_amount', 'max_redemption_amount', |
||||
|
'redemption_frequency', |
||||
|
'redemption_frequency_unit', 'redemption_eligibility', |
||||
|
'max_redemption_type']) |
||||
|
return result |
||||
|
|
||||
|
def _loader_params_res_partner(self): |
||||
|
result = super()._loader_params_res_partner() |
||||
|
result['search_params']['fields'].extend(['pos_order_ids']) |
||||
|
return result |
@ -0,0 +1,58 @@ |
|||||
|
# -*- 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, models, fields |
||||
|
|
||||
|
|
||||
|
class ResPartner(models.Model): |
||||
|
"""To show the redemption history in the customer's form""" |
||||
|
_inherit = 'res.partner' |
||||
|
|
||||
|
pos_order_ids = fields.One2many('pos.order', inverse_name="partner_id", |
||||
|
domain="[('partner_id','=',self.id)]") |
||||
|
|
||||
|
def action_view_redemption_history(self): |
||||
|
"""Smart button to view the rewards claimed by the customers""" |
||||
|
order_id = self.env['pos.order'].search( |
||||
|
[('partner_id', '=', self.id)]).ids |
||||
|
return { |
||||
|
'type': 'ir.actions.act_window', |
||||
|
'name': 'Redemption History', |
||||
|
'view_mode': 'tree,form', |
||||
|
'res_model': 'pos.order.line', |
||||
|
'domain': [('is_reward_line', '=', 'true'), |
||||
|
('order_id', 'in', order_id)], |
||||
|
'context': "{'create': False}" |
||||
|
} |
||||
|
|
||||
|
@api.model |
||||
|
def check_redemption(self, pid): |
||||
|
"""to check number of times the reward is claimed""" |
||||
|
order = self.env['pos.order'].search([('partner_id', '=', pid[0])]) |
||||
|
data = [] |
||||
|
date = [] |
||||
|
order_line = self.env['pos.order.line'].search( |
||||
|
[('is_reward_line', '=', 'true'), ('order_id', 'in', order.ids)]) |
||||
|
for line in order_line: |
||||
|
data.append(line.order_id.id) |
||||
|
date.append(line.create_date.date()) |
||||
|
|
||||
|
return data, date |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 565 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 87 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 86 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 482 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 116 KiB |
After Width: | Height: | Size: 164 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 69 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 168 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 112 KiB |
After Width: | Height: | Size: 163 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 140 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 166 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 110 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 165 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 58 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 164 KiB |
After Width: | Height: | Size: 81 KiB |
After Width: | Height: | Size: 70 KiB |
After Width: | Height: | Size: 99 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 192 KiB |