Skip to content

Commit

Permalink
[MIG] Migrate module pos_loyalty to v13.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsolanki-initos authored and hkapatel-initos committed Sep 14, 2021
1 parent e023a00 commit 5c9dd08
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 51 deletions.
1 change: 1 addition & 0 deletions pos_loyalty/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Contributors
* RGB Consulting SL (http://www.rgbconsulting.com)
* Forward-port from Odoo SA saas-6 branch
* Kiril Vangelovski <kiril@lambda-is.com>
* Dhara Solanki <dhara.solanki@initos.com>

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion pos_loyalty/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Loyalty Program",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "Point of Sale",
"license": "AGPL-3",
"author": "OpenERP SA, "
Expand Down
1 change: 0 additions & 1 deletion pos_loyalty/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
from . import loyalty_rule
from . import pos_config
from . import pos_order
from . import pos_order_line
from . import res_partner
6 changes: 3 additions & 3 deletions pos_loyalty/models/loyalty_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class LoyaltyProgram(models.Model):
)
pp_currency = fields.Float(
string="Points per currency",
help="Amount of loyalty points given to the " "customer per sold currency",
help="Amount of loyalty points given to the customer per sold currency",
)
pp_product = fields.Float(
string="Points per product",
help="Amount of loyalty points given to the " "customer per product sold",
help="Amount of loyalty points given to the customer per product sold",
)
pp_order = fields.Float(
string="Points per order",
Expand All @@ -27,7 +27,7 @@ class LoyaltyProgram(models.Model):
rounding = fields.Float(
string="Points Rounding",
default=1,
help="Loyalty point amounts will be rounded to " "multiples of this value",
help="Loyalty point amounts will be rounded to multiples of this value",
)
rule_ids = fields.One2many(
comodel_name="loyalty.rule", inverse_name="loyalty_program_id", string="Rules"
Expand Down
5 changes: 1 addition & 4 deletions pos_loyalty/models/loyalty_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class LoyaltyReward(models.Model):
_name = "loyalty.reward"

name = fields.Char(string="Reward Name", size=32, index=True, required=True)
name = fields.Char(string="Reward Name", required=True)
type = fields.Selection(
selection=[("gift", "Gift"), ("discount", "Discount"), ("resale", "Resale")],
string="Type",
Expand Down Expand Up @@ -54,7 +54,6 @@ class LoyaltyReward(models.Model):
help="Product that represents a point " "that is sold by the customer",
)

@api.multi
@api.constrains("type", "gift_product_id")
def _check_gift_product(self):
for reward in self:
Expand All @@ -63,7 +62,6 @@ def _check_gift_product(self):
_("Gift product field is mandatory for gift rewards")
)

@api.multi
@api.constrains("type", "discount_product_id")
def _check_discount_product(self):
for reward in self:
Expand All @@ -72,7 +70,6 @@ def _check_discount_product(self):
_("Discount product field is " "mandatory for discount rewards")
)

@api.multi
@api.constrains("type", "point_product_id")
def _check_point_product(self):
for reward in self:
Expand Down
2 changes: 1 addition & 1 deletion pos_loyalty/models/loyalty_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class LoyaltyRule(models.Model):
_name = "loyalty.rule"

name = fields.Char(string="Rule Name", size=32, index=True, required=True)
name = fields.Char(string="Rule Name", index=True)
type = fields.Selection(
selection=[("product", "Product"), ("category", "Category")],
string="Type",
Expand Down
2 changes: 1 addition & 1 deletion pos_loyalty/models/pos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class PosConfig(models.Model):
loyalty_id = fields.Many2one(
comodel_name="loyalty.program",
string="Loyalty Program",
help="The loyalty program used by this " "Point of Sale",
help="The loyalty program used by this Point of Sale",
)
2 changes: 1 addition & 1 deletion pos_loyalty/models/pos_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PosOrder(models.Model):

loyalty_points = fields.Float(
string="Loyalty Points",
help="The amount of Loyalty points awarded " "to the customer with this order",
help="The amount of Loyalty points awarded to the customer with this order",
)

@api.model
Expand Down
19 changes: 0 additions & 19 deletions pos_loyalty/models/pos_order_line.py

This file was deleted.

2 changes: 1 addition & 1 deletion pos_loyalty/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class ResPartner(models.Model):

loyalty_points = fields.Float(
string="Loyalty Points",
help="The loyalty points the user won as " "part of a Loyalty Program",
help="The loyalty points the user won as part of a Loyalty Program",
)
1 change: 1 addition & 0 deletions pos_loyalty/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* RGB Consulting SL (http://www.rgbconsulting.com)
* Forward-port from Odoo SA saas-6 branch
* Kiril Vangelovski <kiril@lambda-is.com>
* Dhara Solanki <dhara.solanki@initos.com>
1 change: 0 additions & 1 deletion pos_loyalty/static/src/js/pos.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ odoo.define("pos_loyalty.loyalty_program", function(require) {
var LoyaltyButton = screens.ActionButtonWidget.extend({
template: "LoyaltyButton",
button_click: function() {
var self = this;
var order = this.pos.get_order();
var client = order.get_client();
if (!client) {
Expand Down
29 changes: 13 additions & 16 deletions pos_loyalty/static/src/js/tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2004-2018 Odoo SA
// Copyright 2018 Lambda IS DOOEL <https://www.lambda-is.com>
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
/* eslint-disable no-empty-function, init-declarations */

odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
"use strict";
Expand Down Expand Up @@ -30,7 +31,7 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "Check if customer " + customer_name + " is added",
trigger: '.button.set-customer:contains("' + customer_name + '")',
run: function() {}, // It's a check
run: function() {},
},
];
}
Expand All @@ -57,7 +58,7 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "the " + product_name + " have been added to the order",
trigger: '.order .product-name:contains("' + product_name + '")',
run: function() {}, // It's a check
run: function() {},
},
];
}
Expand All @@ -67,7 +68,7 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "check if " + product_name + " is in order",
trigger: '.orderline .product-name:contains("' + product_name + '")',
run: function() {}, // It's a check
run: function() {},
},
];
}
Expand Down Expand Up @@ -95,16 +96,12 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
return generate_keypad_steps(amount_str, ".payment-numpad");
}

function generate_product_screen_keypad_steps(amount_str) {
return generate_keypad_steps(amount_str, ".numpad");
}

function verify_order_total(total_str) {
return [
{
content: "order total contains " + total_str,
trigger: '.order .total .value:contains("' + total_str + '")',
run: function() {}, // It's a check
run: function() {},
},
];
}
Expand All @@ -131,13 +128,13 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "verify that the order is being sent to the backend",
trigger: ".js_connecting:visible",
run: function() {}, // It's a check
run: function() {},
},
{
content:
"verify that the order has been succesfully sent to the backend",
trigger: ".js_connected:visible",
run: function() {}, // It's a check
run: function() {},
},
{
content: "next order",
Expand All @@ -150,15 +147,15 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "waiting for loading to finish",
trigger: ".o_main_content:has(.loader:hidden)",
run: function() {}, // It's a check
run: function() {},
},
];

steps = steps.concat(add_customer("Agrolait"));
steps = steps.concat(add_product_to_order("Peaches"));
steps = steps.concat(verify_order_total("5.10"));

steps = steps.concat(add_product_to_order("Peaches")); // Buy another kg of peaches
steps = steps.concat(add_product_to_order("Peaches"));
steps = steps.concat(verify_order_total("10.20"));
steps = steps.concat(goto_payment_screen_and_select_payment_method());
steps = steps.concat(generate_payment_screen_keypad_steps("12.20"));
Expand All @@ -167,12 +164,12 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "verify tendered",
trigger: '.col-tendered:contains("12.20")',
run: function() {}, // It's a check
run: function() {},
},
{
content: "verify change",
trigger: '.col-change:contains("2.00")',
run: function() {}, // It's a check
run: function() {},
},
]);

Expand All @@ -191,7 +188,7 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "waiting for loading to finish",
trigger: ".o_main_content:has(.loader:hidden)",
run: function() {}, // It's a check
run: function() {},
},
];
steps = steps.concat(add_customer("Agrolait"));
Expand All @@ -203,7 +200,7 @@ odoo.define("pos_loyalty.tour.test_pos_loyalty", function(require) {
{
content: "verify tendered",
trigger: '.col-tendered:contains("0.00")',
run: function() {}, // It's a check
run: function() {},
},
]);
steps = steps.concat(finish_order());
Expand Down
1 change: 1 addition & 0 deletions pos_loyalty/tests/test_pos_loyalty.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Copyright 2018 Lambda IS DOOEL <https://www.lambda-is.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo.tests import HttpCase


Expand Down
1 change: 0 additions & 1 deletion pos_loyalty/views/loyalty_program_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<field name="name">Loyalty Programs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">loyalty.program</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Expand Down
3 changes: 2 additions & 1 deletion pos_loyalty/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
type="action"
name="%(point_of_sale.action_pos_pos_form)d"
context="{'search_default_partner_id': active_id,'default_partner_id': active_id}"
attrs="{'invisible': ['|', ('customer', '=', False), ('pos_order_count', '=', 0)]}"
attrs="{'invisible': ['|', ('customer_rank', '=', 0), ('pos_order_count', '=', 0)]}"
icon="fa-star"
>
<field name="loyalty_points" widget="statinfo" />
<field name="customer_rank" invisible="1" />
</button>
</button>
</field>
Expand Down

0 comments on commit 5c9dd08

Please sign in to comment.