-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] website_sale_product_compatibility and website_sale_product_contract_gift #351
Merged
github-grap-bot
merged 22 commits into
16.0
from
16.0-add-website_sale_product_contract_gift
Mar 27, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6e8ff34
[ADD] website_sale_product_compatibility
remytms 96eeae1
[ADD] website_sale_product_contract_gift
remytms 4202f1f
[ADD] website_sale_product_contract_gift: add date for gift
remytms a3d82cd
[ADD] website_sale_product_contract_gift: create contract for gift
remytms 175e624
[FIX] website_sale_product_contract_gift: prevent skipping address ch…
remytms a4b7b25
[FIX] website_sale_product_contract_gift: mandatory email
remytms 3ea17b2
[IMP] website_sale_product_contract_gift: change partner and create user
remytms b0c839b
[FIX] website_sale_product_contract_gift: show email error
remytms 282ef53
[FIX] website_sale_product_contract_gift: configure recurrence on con…
remytms 01126fa
[FIX] website_sale_product_contract_gift: constraint on sale.order
remytms 5f9fc1e
[FIX] website_sale_product_contract_gift: error in compute gift_date
remytms 944c25d
[IMP] website_sale_product_compatibility: improvement without changes
remytms eabae42
[IMP] website_sale_product_contract_gift: cosmetic changes
remytms dc360a2
[FIX] add-website_sale_product_contract_gift: find existing partner
remytms 209a068
[REF] website_sale_product_contract_gift: use new js system
remytms 20bbd65
[FIX] website_sale_product_contract_gift: product compatibility
remytms e80e4f4
[IMP] website_sale_product_contract_gift: auto confirm gift order
remytms 70c1aff
[REM] website_sale_product_contract_gift: remove cron
remytms e167cc3
[FIX] website_sale_product_contract_gift: wrong i18n
remytms 864cc6a
[REF] website_sale_product_contract_gift: use mapped only on non-rela…
remytms 35e5766
[FIX] website_sale_product_contract_gift: missing dependency
remytms 2f686ad
[REF] website_sale_product_contract_gift: use test domain instead of …
remytms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
setup/website_sale_product_compatibility/odoo/addons/website_sale_product_compatibility
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_compatibility |
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, | ||
) |
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,75 @@ | ||
================================== | ||
Website Sale Product Compatibility | ||
================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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_compatibility | ||
:alt: coopiteasy/addons | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This is a utility module that can be used by other modules to check | ||
whether different products are allowed to be added to the same | ||
e-commerce sale order. | ||
|
||
This module works only if the user is redirected to the basket after | ||
adding a product to it. If not no message will be displayed to the user. | ||
|
||
**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_compatibility%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_compatibility>`_ 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,5 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
from . import models | ||
from . import controllers |
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,22 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
{ | ||
"name": "Website Sale Product Compatibility", | ||
"summary": """ | ||
Generic module to add compatibility check between products.""", | ||
"version": "16.0.1.0.0", | ||
"category": "E-Commerce", | ||
"website": "https://github.com/coopiteasy/addons", | ||
"author": "Coop IT Easy SC", | ||
"maintainers": ["remytms"], | ||
"license": "AGPL-3", | ||
"application": False, | ||
"depends": [ | ||
"website_sale", | ||
], | ||
"data": [ | ||
"views/templates.xml", | ||
], | ||
} |
File renamed without changes.
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
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 sale_order |
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,47 @@ | ||
# SPDX-FileCopyrightText: 2024 Coop IT Easy SC | ||
# | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
|
||
from odoo import models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
_inherit = "sale.order" | ||
|
||
def check_product_compatibility(self, product_id): | ||
"""Override this function to detect incompatibility between | ||
products. | ||
|
||
Warning: self.ensure_one() | ||
|
||
If an empty string is returned then the product_id is compatible | ||
and will be added to the sale order. If a warning string is | ||
returned then the product is considered not compatible with the | ||
order and the product will not be added to the order. | ||
|
||
By default this method always return no warning message. | ||
|
||
:product_id: The id of the product to check compatibility. | ||
:rtype: str | ||
:return: warning message to be shown on the web interface. | ||
""" | ||
self.ensure_one() | ||
return "" | ||
|
||
def _cart_update(self, product_id, line_id=None, add_qty=0, set_qty=0, **kwargs): | ||
"""Prevent incompatible product to be added to the cart.""" | ||
self.ensure_one() | ||
warning = self.check_product_compatibility(product_id) | ||
if warning: | ||
add_qty = None | ||
set_qty = 0 | ||
values = super()._cart_update( | ||
product_id=product_id, | ||
line_id=line_id, | ||
add_qty=add_qty, | ||
set_qty=set_qty, | ||
**kwargs, | ||
) | ||
values["warning"] = warning | ||
return values |
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,6 @@ | ||
This is a utility module that can be used by other modules to check | ||
whether different products are allowed to be added to the same | ||
e-commerce sale order. | ||
|
||
This module works only if the user is redirected to the basket after | ||
adding a product to it. If not no message will be displayed to the user. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that returning
None
is more clean than an empty string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel strange to return
None
when you attend to receive a string in return. Or I should check type of returned object when using this method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the empty string in this case is actually used as a special value: if it is an empty string, it means that there is no problem: it is thus never used as a string.
replacing it with
None
will not break the existing code that is checking whether the return value is truthy. but it will allow to write it in a cleaner (more explicit) way:there are only 2 cases to handle:
None
, meaning that there is no warning.to me,
None
means “there is no warning”, while the current code feels more like “there is an empty warning” (which makes not much sense). with this change, it even allows to have a warning with an empty message (not very useful, but it illustrates the difference).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
return None
trigger a pylint issue, because we are assigning None from a method to a variable. I made a suggestion.