-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] website_sale_product_contract_gift
Add product contract that can be set as gift and therefore generate some specific compatibilities and flow.
- Loading branch information
Showing
13 changed files
with
679 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/website_sale_product_contract_gift/odoo/addons/website_sale_product_contract_gift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../website_sale_product_contract_gift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
================================== | ||
Website Sale Product Contract Gift | ||
================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:a25ed6054ea1e7db1fe6f90cdb8102edd80859c7504cc1cebdaae1a0123c4819 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |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-coopiteasy%2Faddons-lightgray.png?logo=github | ||
:target: https://github.com/coopiteasy/addons/tree/16.0/website_sale_product_contract_gift | ||
:alt: coopiteasy/addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
Form to order subscription product | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/addons/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/coopiteasy/addons/issues/new?body=module:%20website_sale_product_contract_gift%0Aversion:%2016.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 | ||
~~~~~~~ | ||
|
||
* Coop IT Easy SC | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Coop IT Easy SC <https://coopiteasy.be>`_: | ||
|
||
* Rémy Taymans | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
.. |maintainer-remytms| image:: https://github.com/remytms.png?size=40px | ||
:target: https://github.com/remytms | ||
:alt: remytms | ||
|
||
Current maintainer: | ||
|
||
|maintainer-remytms| | ||
|
||
This module is part of the `coopiteasy/addons <https://github.com/coopiteasy/addons/tree/16.0/website_sale_product_contract_gift>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
{ | ||
"name": "Website Sale Product Contract Gift", | ||
"summary": """ | ||
Configure product contract to be a gift to someone else.""", | ||
"version": "16.0.1.0.0", | ||
"category": "Website", | ||
"website": "https://github.com/coopiteasy/addons", | ||
"author": "Coop IT Easy SC", | ||
"maintainers": ["remytms"], | ||
"license": "AGPL-3", | ||
"application": False, | ||
"depends": [ | ||
"website_sale_product_compatibility", | ||
"product_contract", | ||
], | ||
"excludes": [], | ||
"data": [ | ||
"views/product_views.xml", | ||
], | ||
"demo": [], | ||
"qweb": [], | ||
} |
69 changes: 69 additions & 0 deletions
69
website_sale_product_contract_gift/i18n/website_sale_restrict_sepa_dd.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * website_sale_restrict_sepa_dd | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.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: website_sale_restrict_sepa_dd | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_product_product__allow_sepa_dd_payment | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_product_template__allow_sepa_dd_payment | ||
msgid "Allow SEPA Direct Debit Payment" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#. odoo-python | ||
#: code:addons/website_sale_restrict_sepa_dd/models/product_template.py:0 | ||
#, python-format | ||
msgid "" | ||
"Allow SEPA Direct Debit payment for the product in ordre to set Only SEPA " | ||
"Direct Debit payment." | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_sale_order__allow_sepa_dd_payment | ||
msgid "Allow Sepa Dd Payment" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#. odoo-python | ||
#: code:addons/website_sale_restrict_sepa_dd/models/sale_order.py:0 | ||
#, python-format | ||
msgid "" | ||
"Cannot add product that does not allow SEPA Direct Debit with products that " | ||
"allow only SEPA Direct Debit payment." | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_product_product__only_sepa_dd_payment | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_product_template__only_sepa_dd_payment | ||
msgid "Only SEPA Direct Debit Payment" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model.fields,field_description:website_sale_restrict_sepa_dd.field_sale_order__only_sepa_dd_payment | ||
msgid "Only Sepa Dd Payment" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model,name:website_sale_restrict_sepa_dd.model_payment_provider | ||
msgid "Payment Provider" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model,name:website_sale_restrict_sepa_dd.model_product_template | ||
msgid "Product" | ||
msgstr "" | ||
|
||
#. module: website_sale_restrict_sepa_dd | ||
#: model:ir.model,name:website_sale_restrict_sepa_dd.model_sale_order | ||
msgid "Sales Order" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from . import product_template |
11 changes: 11 additions & 0 deletions
11
website_sale_product_contract_gift/models/product_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
is_gift = fields.Boolean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
|
||
from odoo import _, api, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
@api.constrains("order_line") | ||
def _check_gift_alone(self): | ||
"""Ensure gift are not mixed in a sale order.""" | ||
for order in self: | ||
at_least_one_gift = any( | ||
order.order_line.mapped("product_id").mapped("is_gift") | ||
) | ||
is_all_gift = all(order.order_line.mapped("product_id").mapped("is_gift")) | ||
if at_least_one_gift and not is_all_gift: | ||
raise ValidationError( | ||
_( | ||
"Cannot add product gift in an order that " | ||
"contains other product that are not gifts." | ||
) | ||
) | ||
|
||
def check_product_compatibility(self, product_id): | ||
warning = super().check_product_compatibility(product_id) | ||
if not warning: | ||
product = self.env["product.product"].browse(product_id).exists() | ||
non_gifts = self.order_line.mapped("product_id").filtered( | ||
lambda p: not p.is_gift | ||
) | ||
is_all_gift = all(self.order_line.mapped("product_id").mapped("is_gift")) | ||
if product: | ||
if product.is_gift and non_gifts: | ||
warning = _( | ||
f"Product {product.name} cannot be added because " | ||
"it's a gift and gift must be purchase seperatly." | ||
) | ||
elif not product.is_gift and is_all_gift: | ||
warning = _( | ||
f"Product {product.name} cannot be added because " | ||
"it is not a gift and other product are gifts." | ||
) | ||
return warning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* `Coop IT Easy SC <https://coopiteasy.be>`_: | ||
|
||
* Rémy Taymans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Form to order subscription product |
Oops, something went wrong.