Skip to content

Commit

Permalink
[IMP] coupon_incompatibility, sale_coupon_incompatibility
Browse files Browse the repository at this point in the history
Allow coupon_incompatibility settings to be used by other modules.
  • Loading branch information
stefan-tecnativa authored and pilarvargas-tecnativa committed Jan 29, 2024
1 parent 4743b2b commit e403cc0
Show file tree
Hide file tree
Showing 16 changed files with 844 additions and 0 deletions.
94 changes: 94 additions & 0 deletions loyalty_incompatibility/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
========================
Coupon incompatibilities
========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png
:target: https://odoo-community.org/page/development-status
:alt: Production/Stable
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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_incompatibility
: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_incompatibility
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/296/15.0
:alt: Try me on Runbot

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

Base module to handle incompatibility between promotions and coupons

**Table of contents**

.. contents::
:local:

Configuration
=============

To configure promotion incompatibilities (either coupons or promotion programs):

#. Go to *Sales > Products > Coupon Programs* and select or create a new one.
#. In the *Incompatible Promotions* set the promotions that aren't compatible with the
one you're configuring.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/sale-promotion/issues/new?body=module:%20coupon_incompatibility%0Aversion:%2015.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>`_:

* Pedro M. Baeza
* David Vidal
* Stefan Ungureanu

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-chienandalu| image:: https://github.com/chienandalu.png?size=40px
:target: https://github.com/chienandalu
:alt: chienandalu

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/15.0/coupon_incompatibility>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions loyalty_incompatibility/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions loyalty_incompatibility/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2021 Tecnativa - David Vidal
# Copyright 2023 Tecnativa - Stefan Ungureanu
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Coupon incompatibilities",
"summary": "Allows to set incompatibility rules between promotions",
"version": "15.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/sale_coupon_program_views.xml"],
}
24 changes: 24 additions & 0 deletions loyalty_incompatibility/i18n/coupon_incompatibility.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * coupon_incompatibility
#
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_incompatibility
#: model:ir.model,name:coupon_incompatibility.model_coupon_program
msgid "Coupon display on a website"
msgstr ""

#. module: coupon_incompatibility
#: model:ir.model.fields,field_description:coupon_incompatibility.field_coupon_program__incompatible_promotion_ids
msgid "Incompatible Promotions"
msgstr ""
28 changes: 28 additions & 0 deletions loyalty_incompatibility/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * coupon_incompatibility
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-02 10:25+0000\n"
"PO-Revision-Date: 2023-02-02 11:27+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: es_ES\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.2.2\n"

#. module: coupon_incompatibility
#: model:ir.model,name:coupon_incompatibility.model_coupon_program
msgid "Coupon Program"
msgstr "Programa de cupones"

#. module: coupon_incompatibility
#: model:ir.model.fields,field_description:coupon_incompatibility.field_coupon_program__incompatible_promotion_ids
msgid "Incompatible Promotions"
msgstr "Promociones incompatibles"
1 change: 1 addition & 0 deletions loyalty_incompatibility/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import coupon_program
34 changes: 34 additions & 0 deletions loyalty_incompatibility/models/coupon_program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2021 Tecnativa - David Vidal
# Copyright 2023 Tecnativa - Stefan Ungureanu
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class CouponProgram(models.Model):
_inherit = "coupon.program"

incompatible_promotion_ids = fields.Many2many(
comodel_name="coupon.program",
relation="sale_coupon_program_incompatibility_rel",
column1="program_id",
column2="incompatible_program_id",
inverse="_inverse_incompatible_promotion_ids",
string="Incompatible Promotions",
)

def _inverse_incompatible_promotion_ids(self):
"""We'll be ensuring that any program that could have been removed from the
field will be compatible again and that any new program in the field will
be incompatible with this one. So we will ensure that A ⊥ B as B ⊥ A"""
for program in self:
incompatible_programs = self.search(
[
("incompatible_promotion_ids", "in", program.ids),
("id", "!=", program.id),
]
)
to_remove_programs = (
incompatible_programs - program.incompatible_promotion_ids
)
program.incompatible_promotion_ids.incompatible_promotion_ids |= program
to_remove_programs.incompatible_promotion_ids -= program
5 changes: 5 additions & 0 deletions loyalty_incompatibility/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To configure promotion incompatibilities (either coupons or promotion programs):

#. Go to *Sales > Products > Coupon Programs* and select or create a new one.
#. In the *Incompatible Promotions* set the promotions that aren't compatible with the
one you're configuring.
5 changes: 5 additions & 0 deletions loyalty_incompatibility/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Pedro M. Baeza
* David Vidal
* Stefan Ungureanu
1 change: 1 addition & 0 deletions loyalty_incompatibility/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Base module to handle incompatibility between promotions and coupons
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 141 additions & 0 deletions loyalty_incompatibility/static/description/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e403cc0

Please sign in to comment.