Skip to content

Commit

Permalink
[IMP] sale_loyalty_limit: pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arantxa-s73 committed Jan 14, 2025
1 parent e7f3aac commit 843d93e
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 95 deletions.
72 changes: 39 additions & 33 deletions sale_loyalty_limit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ 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/16.0/sale_loyalty_limit
:target: https://github.com/OCA/sale-promotion/tree/17.0/sale_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-16-0/sale-promotion-16-0-sale_loyalty_limit
:target: https://translation.odoo-community.org/projects/sale-promotion-17-0/sale-promotion-17-0-sale_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=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to configure a limit on the times a promotion can be applied. Two
limits can be configured: customer and salesman. Those limits apply to either programs
or coupons.
This module allows to configure a limit on the times a promotion can be
applied. Two limits can be configured: customer and salesman. Those
limits apply to either programs or coupons.

**Table of contents**

Expand All @@ -42,66 +42,72 @@ Configuration

To configure customer limits:

#. Go to *Sales > Products > Discount & Loyalty* and select or create a new one.
#. Set the *Maximum Customer Applications* to the number of times a program can be used
by a customer.
1. Go to *Sales > Products > Discount & Loyalty* and select or create a
new one.
2. Set the *Maximum Customer Applications* to the number of times a
program can be used by a customer.

NOTE: The customer limit is applied at commercial entity level, not for each contact
inside the entity.
NOTE: The customer limit is applied at commercial entity level, not for
each contact inside the entity.

To configure salesmen limits:

#. Go to *Sales > Products > Discount & Loyalty* and select or create a new one.
#. Add salesmen to the *Salesmen Limits* list and their maximum number of applications.
#. You can add different limits to different salesmen groups.
#. If you want to constrain the use of the promotion to the salesmen list, set the
option *Strict limit* on, so any other salesman won't be able to apply the promotion.
1. Go to *Sales > Products > Discount & Loyalty* and select or create a
new one.
2. Add salesmen to the *Salesmen Limits* list and their maximum number
of applications.
3. You can add different limits to different salesmen groups.
4. If you want to constrain the use of the promotion to the salesmen
list, set the option *Strict limit* on, so any other salesman won't
be able to apply the promotion.

Usage
=====

Once the program limits are configured, apply the programs as usual in your sale orders.
Once the program limits are configured, apply the programs as usual in
your sale orders.

Once the limit for a customer or a salesman is reached, if we try to apply a promotion:
Once the limit for a customer or a salesman is reached, if we try to
apply a promotion:

- A code promotion will raise an error.
- A program with no code won't be applied.
- A coupon belonging to a limited program will raise an error.
- A promotion applied on the next order won't generate the coupon.
- A code promotion will raise an error.
- A program with no code won't be applied.
- A coupon belonging to a limited program will raise an error.
- A promotion applied on the next order won't generate the coupon.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-promotion/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 <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_loyalty_limit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_loyalty_limit%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~
-------

* Tecnativa

Contributors
~~~~~~~~~~~~
------------

* `Tecnativa <https://www.tecnativa.com>`_:
- `Tecnativa <https://www.tecnativa.com>`__:

* Pedro M. Baeza
* David Vidal
* Pilar Vargas
- Pedro M. Baeza
- David Vidal
- Pilar Vargas

* `Akretion <https://www.akretion.com>`_:
- `Akretion <https://www.akretion.com>`__:

* Florian Mounier
- Florian Mounier

Maintainers
~~~~~~~~~~~
-----------

This module is maintained by the OCA.

Expand All @@ -121,6 +127,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-chienandalu|

This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/16.0/sale_loyalty_limit>`_ project on GitHub.
This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/17.0/sale_loyalty_limit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
20 changes: 10 additions & 10 deletions sale_loyalty_limit/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def _program_check_compute_points(self, programs):
if limit_reached and self.applied_coupon_ids:
res[program] = {
"error": _(
"This promo code was already applied %(count)s times for this "
"customer and there's an stablished limit of %(max)s for this "
"promotion."
"This promo code was already applied %(count)s times "
"for this customer and there's an stablished limit "
"of %(max)s for this promotion."
)
% {
"count": order_count,
Expand All @@ -54,10 +54,10 @@ def _program_check_compute_points(self, programs):
if salesman_rule:
max_rule = salesman_rule.max_salesman_application
# It is necessary to recalculate the number of times it has been used
# omitting the current sell order because when a sell order is confirmed,
# the "_update_programs_and_rewards" method is re-executed which triggers
# the compute method again and in this method the current sell order is
# not excluded.
# omitting the current sell order because when a sell order
# is confirmed, the "_update_programs_and_rewards" method is
# re-executed which triggers the compute method again and in
# this method the current sell order is not excluded.
times_used = len(
self.env["sale.order.line"].read_group(
[
Expand All @@ -79,9 +79,9 @@ def _program_check_compute_points(self, programs):
if times_used >= max_rule:
res[program] = {
"error": _(
"This promo code was already applied %(times)s times for this "
"salesman and there's an stablished limit of %(max)s for this "
"promotion."
"This promo code was already applied %(times)s times "
"for this salesman and there's an stablished limit "
"of %(max)s for this promotion."
)
% {"times": times_used, "max": max_rule}
}
Expand Down
3 changes: 3 additions & 0 deletions sale_loyalty_limit/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
20 changes: 20 additions & 0 deletions sale_loyalty_limit/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
To configure customer limits:

1. Go to *Sales \> Products \> Discount & Loyalty* and select or create
a new one.
2. Set the *Maximum Customer Applications* to the number of times a
program can be used by a customer.

NOTE: The customer limit is applied at commercial entity level, not for
each contact inside the entity.

To configure salesmen limits:

1. Go to *Sales \> Products \> Discount & Loyalty* and select or create
a new one.
2. Add salesmen to the *Salesmen Limits* list and their maximum number
of applications.
3. You can add different limits to different salesmen groups.
4. If you want to constrain the use of the promotion to the salesmen
list, set the option *Strict limit* on, so any other salesman won't
be able to apply the promotion.
16 changes: 0 additions & 16 deletions sale_loyalty_limit/readme/CONFIGURE.rst

This file was deleted.

6 changes: 6 additions & 0 deletions sale_loyalty_limit/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [Tecnativa](https://www.tecnativa.com):
- Pedro M. Baeza
- David Vidal
- Pilar Vargas
- [Akretion](https://www.akretion.com):
- Florian Mounier
9 changes: 0 additions & 9 deletions sale_loyalty_limit/readme/CONTRIBUTORS.rst

This file was deleted.

3 changes: 3 additions & 0 deletions sale_loyalty_limit/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module allows to configure a limit on the times a promotion can be
applied. Two limits can be configured: customer and salesman. Those
limits apply to either programs or coupons.
3 changes: 0 additions & 3 deletions sale_loyalty_limit/readme/DESCRIPTION.rst

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Once the program limits are configured, apply the programs as usual in your sale orders.
Once the program limits are configured, apply the programs as usual in
your sale orders.

Once the limit for a customer or a salesman is reached, if we try to apply a promotion:
Once the limit for a customer or a salesman is reached, if we try to
apply a promotion:

- A code promotion will raise an error.
- A program with no code won't be applied.
Expand Down
Loading

0 comments on commit 843d93e

Please sign in to comment.