Skip to content

Commit 38206ee

Browse files
[IMP] coupon_incompatibility, sale_coupon_incompatibility
Allow coupon_incompatibility settings to be used by other modules.
1 parent ff6cbf5 commit 38206ee

12 files changed

+123
-183
lines changed

sale_loyalty_incompatibility/README.rst

+14-21
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
Coupon incompatibilities
33
========================
44

5-
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
67
!! This file is generated by oca-gen-addon-readme !!
78
!! changes will be overwritten. !!
89
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5f10374003403bbcd364cf5e67d597e54a8528030be49132d4fda54d30f4df16
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
912
1013
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
1114
:target: https://odoo-community.org/page/development-status
@@ -14,16 +17,16 @@ Coupon incompatibilities
1417
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1518
:alt: License: AGPL-3
1619
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github
17-
:target: https://github.com/OCA/sale-promotion/tree/13.0/sale_coupon_incompatibility
20+
:target: https://github.com/OCA/sale-promotion/tree/15.0/sale_coupon_incompatibility
1821
:alt: OCA/sale-promotion
1922
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20-
:target: https://translation.odoo-community.org/projects/sale-promotion-13-0/sale-promotion-13-0-sale_coupon_incompatibility
23+
:target: https://translation.odoo-community.org/projects/sale-promotion-15-0/sale-promotion-15-0-sale_coupon_incompatibility
2124
:alt: Translate me on Weblate
22-
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/296/13.0
24-
:alt: Try me on Runbot
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&target_branch=15.0
27+
:alt: Try me on Runboat
2528

26-
|badge1| |badge2| |badge3| |badge4| |badge5|
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
2730

2831
This module allows to set incompatibilities between promotions, so when a promotion A
2932
is not compatible with promotion B, they can't be applied together in a sales order.
@@ -33,17 +36,6 @@ is not compatible with promotion B, they can't be applied together in a sales or
3336
.. contents::
3437
:local:
3538

36-
Configuration
37-
=============
38-
39-
To configure promotion incompatibilities (either coupons or promotion programs):
40-
41-
#. Go to *Sales > Catalog > Coupon Programs* and select or create a new one.
42-
#. In the *Incompatible Promotions* set the promotions that aren't compatible with the
43-
one you're configuring.
44-
#. Once set, the those promotions will have your configured promotion as incompatible
45-
as well, so they can't be used altogether in the same sale order.
46-
4739
Usage
4840
=====
4941

@@ -58,8 +50,8 @@ Bug Tracker
5850

5951
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-promotion/issues>`_.
6052
In case of trouble, please check there if your issue has already been reported.
61-
If you spotted it first, help us smashing it by providing a detailed and welcomed
62-
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_coupon_incompatibility%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
If you spotted it first, help us to smash it by providing a detailed and welcomed
54+
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20sale_coupon_incompatibility%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
6355

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

@@ -78,6 +70,7 @@ Contributors
7870

7971
* Pedro M. Baeza
8072
* David Vidal
73+
* Stefan Ungureanu
8174

8275
Maintainers
8376
~~~~~~~~~~~
@@ -100,6 +93,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
10093

10194
|maintainer-chienandalu|
10295

103-
This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/13.0/sale_coupon_incompatibility>`_ project on GitHub.
96+
This module is part of the `OCA/sale-promotion <https://github.com/OCA/sale-promotion/tree/15.0/sale_coupon_incompatibility>`_ project on GitHub.
10497

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

sale_loyalty_incompatibility/__manifest__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
"author": "Tecnativa, Odoo Community Association (OCA)",
1111
"maintainers": ["chienandalu"],
1212
"license": "AGPL-3",
13-
"depends": ["sale_coupon"],
14-
"data": ["views/sale_coupon_program_views.xml"],
13+
"depends": ["sale_coupon", "coupon_incompatibility"],
1514
}
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * sale_coupon_incompatibility
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 15.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2023-02-02 10:28+0000\n"
10+
"PO-Revision-Date: 2023-02-02 11:30+0100\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"Language: es_ES\n"
14+
"MIME-Version: 1.0\n"
15+
"Content-Type: text/plain; charset=UTF-8\n"
16+
"Content-Transfer-Encoding: 8bit\n"
17+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
18+
"X-Generator: Poedit 3.2.2\n"
19+
20+
#. module: sale_coupon_incompatibility
21+
#: model:ir.model,name:sale_coupon_incompatibility.model_coupon_coupon
22+
msgid "Coupon"
23+
msgstr "Cupón"
24+
25+
#. module: sale_coupon_incompatibility
26+
#: model:ir.model,name:sale_coupon_incompatibility.model_coupon_program
27+
msgid "Coupon display on a website"
28+
msgstr ""
29+
30+
#. module: sale_coupon_incompatibility
31+
#: code:addons/sale_coupon_incompatibility/models/coupon_program.py:0
32+
#: code:addons/sale_coupon_incompatibility/models/sale_coupon.py:0
33+
#, python-format
34+
msgid ""
35+
"This promotion is incompatible with other set already in the order so it "
36+
"can't be applied."
37+
msgstr ""
38+
"Esta promoción es incompatible con otra ya presente en la orden por lo que "
39+
"no se puede aplicar."
40+
41+
#~ msgid "Coupon Program"
42+
#~ msgstr "Programa de cupones"

sale_loyalty_incompatibility/i18n/sale_coupon_incompatibility.pot

+6-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 13.0\n"
7+
"Project-Id-Version: Odoo Server 15.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"Last-Translator: \n"
1010
"Language-Team: \n"
@@ -14,23 +14,18 @@ msgstr ""
1414
"Plural-Forms: \n"
1515

1616
#. module: sale_coupon_incompatibility
17-
#: model:ir.model.fields,field_description:sale_coupon_incompatibility.field_sale_coupon_program__incompatible_promotion_ids
18-
msgid "Incompatible Promotions"
17+
#: model:ir.model,name:sale_coupon_incompatibility.model_coupon_coupon
18+
msgid "Coupon"
1919
msgstr ""
2020

2121
#. module: sale_coupon_incompatibility
22-
#: model:ir.model,name:sale_coupon_incompatibility.model_sale_coupon
23-
msgid "Sales Coupon"
24-
msgstr ""
25-
26-
#. module: sale_coupon_incompatibility
27-
#: model:ir.model,name:sale_coupon_incompatibility.model_sale_coupon_program
28-
msgid "Sales Coupon Program"
22+
#: model:ir.model,name:sale_coupon_incompatibility.model_coupon_program
23+
msgid "Coupon display on a website"
2924
msgstr ""
3025

3126
#. module: sale_coupon_incompatibility
27+
#: code:addons/sale_coupon_incompatibility/models/coupon_program.py:0
3228
#: code:addons/sale_coupon_incompatibility/models/sale_coupon.py:0
33-
#: code:addons/sale_coupon_incompatibility/models/sale_coupon_program.py:0
3429
#, python-format
3530
msgid ""
3631
"This promotion is incompatible with other set already in the order so it "
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from . import sale_coupon_program
1+
from . import coupon_program
22
from . import sale_coupon
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2021 Tecnativa - David Vidal
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from odoo import _, models
4+
5+
6+
class CouponProgram(models.Model):
7+
_inherit = "coupon.program"
8+
9+
def _check_promo_code(self, order, coupon_code):
10+
"""Promotion incompatibility rules. Check the error strings for a detailed case
11+
detail."""
12+
message = super()._check_promo_code(order, coupon_code)
13+
# Other errors may precede
14+
if message:
15+
return message
16+
order_programs = order.no_code_promo_program_ids + order.code_promo_program_id
17+
order_programs |= (
18+
order.applied_coupon_ids + order.generated_coupon_ids
19+
).mapped("program_id")
20+
if any({x in order_programs for x in self.incompatible_promotion_ids}):
21+
message = {
22+
"error": _(
23+
"This promotion is incompatible with other set already in the "
24+
"order so it can't be applied."
25+
)
26+
}
27+
return message

sale_loyalty_incompatibility/models/sale_coupon.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from odoo import _, models
44

55

6-
class SaleCoupon(models.Model):
6+
class Coupon(models.Model):
77
_inherit = "coupon.coupon"
88

99
def _check_coupon_code(self, order_date, partner_id, **kwargs):
1010
"""Coupon incompatibility rules. Check the error strings for a detailed case
1111
detail."""
12-
order = kwargs.get("order", False)
1312
message = super()._check_coupon_code(order_date, partner_id, **kwargs)
13+
order = kwargs.get("order", False)
1414
# Other errors may precede
1515
if message:
1616
return message

sale_loyalty_incompatibility/models/sale_coupon_program.py

-53
This file was deleted.

sale_loyalty_incompatibility/readme/CONFIGURE.rst

-7
This file was deleted.

0 commit comments

Comments
 (0)