diff --git a/loyalty_limit/README.rst b/loyalty_limit/README.rst index 49f8a4e1e..64855cd86 100644 --- a/loyalty_limit/README.rst +++ b/loyalty_limit/README.rst @@ -1,14 +1,11 @@ -============ -Coupon Limit -============ +============= +Loyalty Limit +============= -.. - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:3397b280713cd1ead33c29fac4f11cb62d90da8af4408c3f8ffb73ba2ced3e8e - !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status @@ -17,16 +14,16 @@ Coupon Limit :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github - :target: https://github.com/OCA/sale-promotion/tree/15.0/coupon_limit + :target: https://github.com/OCA/sale-promotion/tree/16.0/loyalty_limit :alt: OCA/sale-promotion .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/sale-promotion-15-0/sale-promotion-15-0-coupon_limit + :target: https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-loyalty_limit :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=15.0 + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/sale-promotion&target_branch=16.0 :alt: Try me on Runboat -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to configure a limit on the times a promotion can be applied. It's a technical base to be extended with top level functionality (sales, pos). @@ -41,8 +38,8 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -61,6 +58,7 @@ Contributors * Pedro M. Baeza * David Vidal + * Pilar Vargas * `Akretion `_: @@ -87,6 +85,6 @@ Current `maintainer `__: |maintainer-chienandalu| -This module is part of the `OCA/sale-promotion `_ project on GitHub. +This module is part of the `OCA/sale-promotion `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/loyalty_limit/__manifest__.py b/loyalty_limit/__manifest__.py index da24626bc..0a12ebc5d 100644 --- a/loyalty_limit/__manifest__.py +++ b/loyalty_limit/__manifest__.py @@ -1,15 +1,15 @@ # Copyright 2021 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { - "name": "Coupon Limit", + "name": "Loyalty Limit", "summary": "Restrict number of promotions per customer or salesman", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "development_status": "Production/Stable", "category": "Sale", "website": "https://github.com/OCA/sale-promotion", "author": "Tecnativa, Odoo Community Association (OCA)", "maintainers": ["chienandalu"], "license": "AGPL-3", - "depends": ["coupon"], - "data": ["views/coupon_program_views.xml", "security/ir.model.access.csv"], + "depends": ["loyalty"], + "data": ["views/loyalty_program_views.xml", "security/ir.model.access.csv"], } diff --git a/loyalty_limit/i18n/coupon_limit.pot b/loyalty_limit/i18n/coupon_limit.pot deleted file mode 100644 index b743b24f2..000000000 --- a/loyalty_limit/i18n/coupon_limit.pot +++ /dev/null @@ -1,170 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * coupon_limit -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" -"Report-Msgid-Bugs-To: \n" -"Last-Translator: \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" -"Plural-Forms: \n" - -#. module: coupon_limit -#: model:ir.model,name:coupon_limit.model_coupon_rule -msgid "Coupon Rule" -msgstr "" - -#. module: coupon_limit -#: model:ir.model,name:coupon_limit.model_coupon_rule_salesmen_limit -msgid "Coupon Rule Salesmen limits" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__create_uid -msgid "Created by" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__create_date -msgid "Created on" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__display_name -msgid "Display Name" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__id -msgid "ID" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,help:coupon_limit.field_coupon_program__rule_salesmen_strict_limit -#: model:ir.model.fields,help:coupon_limit.field_coupon_rule__rule_salesmen_strict_limit -msgid "" -"If marked, promotion will only be allowed for the list of salesmen with " -"their quantities" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit____last_update -msgid "Last Modified on" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__write_uid -msgid "Last Updated by" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__write_date -msgid "Last Updated on" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "Max" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "Max. Customer Applications" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "Max. Salesmen Applications" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_program__rule_max_customer_application -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule__rule_max_customer_application -msgid "Maximum Customer Applications" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__rule_max_salesman_application -msgid "Maximum Salesman Applications" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,help:coupon_limit.field_coupon_rule_salesmen_limit__rule_max_salesman_application -msgid "Maximum times a salesman can apply a program. 0 for no limit." -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,help:coupon_limit.field_coupon_program__rule_salesmen_limit_ids -#: model:ir.model.fields,help:coupon_limit.field_coupon_rule__rule_salesmen_limit_ids -msgid "Maximum times salesmen can apply a program. Empty for no limit." -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,help:coupon_limit.field_coupon_program__rule_max_customer_application -#: model:ir.model.fields,help:coupon_limit.field_coupon_rule__rule_max_customer_application -msgid "" -"Maximum times that a program can be applied to a customer. 0 for no limit." -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__rule_id -msgid "Rule" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__rule_user_id -msgid "Salesman" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_program__rule_salesmen_limit_ids -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule__rule_salesmen_limit_ids -msgid "Salesmen Limits" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_program__rule_salesmen_limit_count -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule__rule_salesmen_limit_count -msgid "Salesmen maximum promotions" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_program__rule_salesmen_limit_used_count -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule__rule_salesmen_limit_used_count -msgid "Salesmen promotions used" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_program__rule_salesmen_strict_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule__rule_salesmen_strict_limit -msgid "Strict limit" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.constraint,message:coupon_limit.constraint_coupon_rule_salesmen_limit_user_id_uniq -msgid "This salesman limit is already configured" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "Total limit" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "Total used" -msgstr "" - -#. module: coupon_limit -#: model:ir.model.fields,field_description:coupon_limit.field_coupon_rule_salesmen_limit__rule_times_used -msgid "Uses" -msgstr "" - -#. module: coupon_limit -#: model_terms:ir.ui.view,arch_db:coupon_limit.sale_coupon_program_view_form_common -msgid "used already)" -msgstr "" diff --git a/loyalty_limit/i18n/loyalty_limit.pot b/loyalty_limit/i18n/loyalty_limit.pot new file mode 100644 index 000000000..dc6761d19 --- /dev/null +++ b/loyalty_limit/i18n/loyalty_limit.pot @@ -0,0 +1,170 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * loyalty_limit +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_coupon_rule +msgid "Coupon Rule" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model,name:loyalty_limit.model_coupon_rule_salesmen_limit +msgid "Coupon Rule Salesmen limits" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__create_uid +msgid "Created by" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__create_date +msgid "Created on" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__display_name +msgid "Display Name" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__id +msgid "ID" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_coupon_program__rule_salesmen_strict_limit +#: model:ir.model.fields,help:loyalty_limit.field_coupon_rule__rule_salesmen_strict_limit +msgid "" +"If marked, promotion will only be allowed for the list of salesmen with " +"their quantities" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit____last_update +msgid "Last Modified on" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__write_uid +msgid "Last Updated by" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__write_date +msgid "Last Updated on" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "Max" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "Max. Customer Applications" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "Max. Salesmen Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_program__rule_max_customer_application +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule__rule_max_customer_application +msgid "Maximum Customer Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__rule_max_salesman_application +msgid "Maximum Salesman Applications" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_coupon_rule_salesmen_limit__rule_max_salesman_application +msgid "Maximum times a salesman can apply a program. 0 for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_coupon_program__rule_salesmen_limit_ids +#: model:ir.model.fields,help:loyalty_limit.field_coupon_rule__rule_salesmen_limit_ids +msgid "Maximum times salesmen can apply a program. Empty for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,help:loyalty_limit.field_coupon_program__rule_max_customer_application +#: model:ir.model.fields,help:loyalty_limit.field_coupon_rule__rule_max_customer_application +msgid "" +"Maximum times that a program can be applied to a customer. 0 for no limit." +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__rule_id +msgid "Rule" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__rule_user_id +msgid "Salesman" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_program__rule_salesmen_limit_ids +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule__rule_salesmen_limit_ids +msgid "Salesmen Limits" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_program__rule_salesmen_limit_count +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule__rule_salesmen_limit_count +msgid "Salesmen maximum promotions" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_program__rule_salesmen_limit_used_count +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule__rule_salesmen_limit_used_count +msgid "Salesmen promotions used" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_program__rule_salesmen_strict_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule__rule_salesmen_strict_limit +msgid "Strict limit" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.constraint,message:loyalty_limit.constraint_coupon_rule_salesmen_limit_user_id_uniq +msgid "This salesman limit is already configured" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "Total limit" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "Total used" +msgstr "" + +#. module: loyalty_limit +#: model:ir.model.fields,field_description:loyalty_limit.field_coupon_rule_salesmen_limit__rule_times_used +msgid "Uses" +msgstr "" + +#. module: loyalty_limit +#: model_terms:ir.ui.view,arch_db:loyalty_limit.sale_coupon_program_view_form_common +msgid "used already)" +msgstr "" diff --git a/loyalty_limit/migrations/15.0.1.0.0/pre-migration.py b/loyalty_limit/migrations/15.0.1.0.0/pre-migration.py deleted file mode 100644 index 09b4680a0..000000000 --- a/loyalty_limit/migrations/15.0.1.0.0/pre-migration.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2023 Tecnativa - David Vidal -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from openupgradelib import openupgrade - -_model_renames = [ - ("sale.coupon.rule.salesmen.limit", "coupon.rule.salesmen.limit"), -] -_table_renames = [("sale_coupon_rule_salesmen_limit", "coupon_rule_salesmen_limit")] - - -@openupgrade.migrate() -def migrate(env, version): - openupgrade.rename_models(env.cr, _model_renames) - openupgrade.rename_tables(env.cr, _table_renames) diff --git a/loyalty_limit/models/__init__.py b/loyalty_limit/models/__init__.py index b6fc8de3e..a1128c3a5 100644 --- a/loyalty_limit/models/__init__.py +++ b/loyalty_limit/models/__init__.py @@ -1 +1 @@ -from . import coupon_rule +from . import loyalty_rule diff --git a/loyalty_limit/models/coupon_rule.py b/loyalty_limit/models/loyalty_rule.py similarity index 96% rename from loyalty_limit/models/coupon_rule.py rename to loyalty_limit/models/loyalty_rule.py index e47d9f97a..ad5a6169a 100644 --- a/loyalty_limit/models/coupon_rule.py +++ b/loyalty_limit/models/loyalty_rule.py @@ -3,8 +3,8 @@ from odoo import api, fields, models -class CouponRule(models.Model): - _inherit = "coupon.rule" +class LoyaltyProgram(models.Model): + _inherit = "loyalty.rule" rule_max_customer_application = fields.Integer( string="Maximum Customer Applications", @@ -48,7 +48,7 @@ class CouponRuleSalesmenLimit(models.Model): _description = "Coupon Rule Salesmen limits" rule_id = fields.Many2one( - comodel_name="coupon.rule", + comodel_name="loyalty.rule", auto_join=True, required=True, ondelete="cascade", diff --git a/loyalty_limit/readme/CONTRIBUTORS.rst b/loyalty_limit/readme/CONTRIBUTORS.rst index a4f45715c..7d6f8b1ad 100644 --- a/loyalty_limit/readme/CONTRIBUTORS.rst +++ b/loyalty_limit/readme/CONTRIBUTORS.rst @@ -2,6 +2,7 @@ * Pedro M. Baeza * David Vidal + * Pilar Vargas * `Akretion `_: diff --git a/loyalty_limit/static/description/icon.svg b/loyalty_limit/static/description/icon.svg index 2f5df826c..e6b472ccf 100644 --- a/loyalty_limit/static/description/icon.svg +++ b/loyalty_limit/static/description/icon.svg @@ -11,7 +11,7 @@ version="1.1" id="svg33" sodipodi:docname="icon.svg" - inkscape:export-filename="/home/david/odoo/oca13/odoo/custom/src/sale-promotion/coupon_limit/static/description/icon.png" + inkscape:export-filename="/home/david/odoo/oca13/odoo/custom/src/sale-promotion/loyalty_limit/static/description/icon.png" inkscape:export-xdpi="192" inkscape:export-ydpi="192" inkscape:version="1.1-dev (1:1.0+devel+202007152027+7044d6c)"> diff --git a/loyalty_limit/static/description/index.html b/loyalty_limit/static/description/index.html index ba0d10eb0..2a50da986 100644 --- a/loyalty_limit/static/description/index.html +++ b/loyalty_limit/static/description/index.html @@ -1,20 +1,20 @@ - + - -Coupon Limit + +Loyalty Limit -
-

Coupon Limit

+
+

Loyalty Limit

-

Production/Stable License: AGPL-3 OCA/sale-promotion Translate me on Weblate Try me on Runboat

+

Production/Stable License: AGPL-3 OCA/sale-promotion Translate me on Weblate Try me on Runboat

This module allows to configure a limit on the times a promotion can be applied. It’s a technical base to be extended with top level functionality (sales, pos).

Table of contents

-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

Current maintainer:

-

chienandalu

-

This module is part of the OCA/sale-promotion project on GitHub.

+

chienandalu

+

This module is part of the OCA/sale-promotion project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/loyalty_limit/tests/__init__.py b/loyalty_limit/tests/__init__.py index 6566525d0..22da88f20 100644 --- a/loyalty_limit/tests/__init__.py +++ b/loyalty_limit/tests/__init__.py @@ -1 +1 @@ -from . import test_coupon_limit +from . import test_loyalty_limit diff --git a/loyalty_limit/tests/test_coupon_limit.py b/loyalty_limit/tests/test_coupon_limit.py deleted file mode 100644 index 8453bf723..000000000 --- a/loyalty_limit/tests/test_coupon_limit.py +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2021 Tecnativa - David Vidal -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests import Form, TransactionCase - - -class CouponLimitCase(TransactionCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - product_obj = cls.env["product.product"] - cls.pricelist = cls.env["product.pricelist"].create( - { - "name": "Test pricelist", - "item_ids": [ - ( - 0, - 0, - { - "applied_on": "3_global", - "compute_price": "formula", - "base": "list_price", - }, - ) - ], - } - ) - cls.partner_1 = cls.env["res.partner"].create( - {"name": "Mr. Odoo", "property_product_pricelist": cls.pricelist.id} - ) - cls.partner_2 = cls.env["res.partner"].create( - {"name": "Mrs. Odoo", "property_product_pricelist": cls.pricelist.id} - ) - cls.salesman_1 = cls.env["res.users"].create( - {"name": "Salesman 1", "login": "test_salesman_1"} - ) - cls.salesman_2 = cls.env["res.users"].create( - {"name": "Salesman 2", "login": "test_salesman_2"} - ) - cls.product_a = product_obj.create({"name": "Product A", "list_price": 50}) - coupon_program_form = Form( - cls.env["coupon.program"], - view="sale_coupon.sale_coupon_program_view_promo_program_form", - ) - coupon_program_form.name = "Test Coupon Limit" - # We don't want demo programs spoiling our tests - coupon_program_form.rule_products_domain = "[('id', '=', %s)]" % ( - cls.product_a.id - ) - coupon_program_form.promo_code_usage = "no_code_needed" - coupon_program_form.reward_type = "discount" - coupon_program_form.discount_apply_on = "on_order" - coupon_program_form.discount_type = "percentage" - coupon_program_form.discount_percentage = 10 - # Customer limits preceed salesmen limits - coupon_program_form.rule_max_customer_application = 2 - with coupon_program_form.rule_salesmen_limit_ids.new() as salesman_limit: - salesman_limit.rule_user_id = cls.salesman_1 - salesman_limit.rule_max_salesman_application = 2 - with coupon_program_form.rule_salesmen_limit_ids.new() as salesman_limit: - salesman_limit.rule_user_id = cls.salesman_2 - salesman_limit.rule_max_salesman_application = 2 - # With any other salesman, the limits won't apply - coupon_program_form.rule_salesmen_strict_limit = False - cls.coupon_program = coupon_program_form.save() diff --git a/loyalty_limit/tests/test_loyalty_limit.py b/loyalty_limit/tests/test_loyalty_limit.py new file mode 100644 index 000000000..196938208 --- /dev/null +++ b/loyalty_limit/tests/test_loyalty_limit.py @@ -0,0 +1,85 @@ +# Copyright 2021 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests import TransactionCase + + +class CouponLimitCase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + product_obj = cls.env["product.product"] + cls.pricelist = cls.env["product.pricelist"].create( + { + "name": "Test pricelist", + "item_ids": [ + ( + 0, + 0, + { + "applied_on": "3_global", + "compute_price": "formula", + "base": "list_price", + }, + ) + ], + } + ) + cls.partner_1 = cls.env["res.partner"].create( + {"name": "Mr. Odoo", "property_product_pricelist": cls.pricelist.id} + ) + cls.partner_2 = cls.env["res.partner"].create( + {"name": "Mrs. Odoo", "property_product_pricelist": cls.pricelist.id} + ) + cls.salesman_1 = cls.env["res.users"].create( + {"name": "Salesman 1", "login": "test_salesman_1"} + ) + cls.salesman_2 = cls.env["res.users"].create( + {"name": "Salesman 2", "login": "test_salesman_2"} + ) + cls.product_a = product_obj.create({"name": "Product A", "list_price": 50}) + cls.loyalty_program = cls.env["loyalty.program"].create( + { + "name": "Test Coupon Limit", + "program_type": "promotion", + "trigger": "auto", + "applies_on": "current", + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + "rule_max_customer_application": 2, + "rule_salesmen_limit_ids": [ + ( + 0, + 0, + { + "rule_user_id": cls.salesman_1.id, + "rule_max_salesman_application": 2, + }, + { + "rule_user_id": cls.salesman_2.id, + "rule_max_salesman_application": 2, + }, + ) + ], + "rule_salesmen_strict_limit": False, + }, + ) + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "required_points": 1, + "discount": 10, + "discount_mode": "percent", + }, + ) + ], + } + ) diff --git a/loyalty_limit/views/coupon_program_views.xml b/loyalty_limit/views/loyalty_program_views.xml similarity index 85% rename from loyalty_limit/views/coupon_program_views.xml rename to loyalty_limit/views/loyalty_program_views.xml index 2e54256e0..7a7fa296e 100644 --- a/loyalty_limit/views/coupon_program_views.xml +++ b/loyalty_limit/views/loyalty_program_views.xml @@ -1,10 +1,10 @@ - - - coupon.program + + + loyalty.rule - +