-
-
Notifications
You must be signed in to change notification settings - Fork 698
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_pricelist_alternative
- Loading branch information
1 parent
5a188cc
commit 90d6f4d
Showing
13 changed files
with
651 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...sale_product_pricelist_alternative/odoo/addons/website_sale_product_pricelist_alternative
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_pricelist_alternative |
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,79 @@ | ||
========================================== | ||
Website Sale Product Pricelist Alternative | ||
========================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-OCA%2Fwebsite-lightgray.png?logo=github | ||
:target: https://github.com/OCA/website/tree/16.0/website_sale_product_pricelist_alternative | ||
:alt: OCA/website | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/website-16-0/website-16-0-website_sale_product_pricelist_alternative | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/website&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
Based on `product_pricelist_alternative` (https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_alternative), it allows you to show in the website alternative vs original product prices. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
In product pricelist select discount policy as `Show public price and discount to the customer`. | ||
In the pricelist used in the website, you can set the alternative pricelist with the discounted price. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/website/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/website/issues/new?body=module:%20website_sale_product_pricelist_alternative%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 | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Telmo Santos <[email protected]> | ||
|
||
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. | ||
|
||
This module is part of the `OCA/website <https://github.com/OCA/website/tree/16.0/website_sale_product_pricelist_alternative>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/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 @@ | ||
from . import models |
20 changes: 20 additions & 0 deletions
20
website_sale_product_pricelist_alternative/__manifest__.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,20 @@ | ||
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Website Sale Product Pricelist Alternative", | ||
"version": "16.0.1.0.0", | ||
"development_status": "Beta", | ||
"category": "Website", | ||
"summary": "Show product alternative price versus original price on website cart", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/website", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"website_sale", | ||
"product_pricelist_alternative", | ||
], | ||
"data": [], | ||
"installable": True, | ||
"auto_install": False, | ||
} |
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 @@ | ||
from . import product_template |
71 changes: 71 additions & 0 deletions
71
website_sale_product_pricelist_alternative/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,71 @@ | ||
# Copyright 2024 Camptocamp (<https://www.camptocamp.com>). | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = "product.template" | ||
|
||
def _get_sales_prices(self, pricelist): | ||
if ( | ||
pricelist | ||
and pricelist.discount_policy == "without_discount" | ||
and self.env.context.get("website_id") | ||
): | ||
pricelist = pricelist.with_context(skip_alternative_pricelist=True) | ||
res = super()._get_sales_prices(pricelist) | ||
for product_id in res: | ||
res[product_id]["base_price"] = res[product_id]["price_reduce"] | ||
pricelist = pricelist.with_context(skip_alternative_pricelist=False) | ||
product = self.env["product.template"].browse(product_id) | ||
res[product_id]["price_reduce"] = pricelist._get_product_price( | ||
product, 1.0 | ||
) | ||
return res | ||
return super()._get_sales_prices(pricelist) | ||
|
||
def _get_combination_info( | ||
self, | ||
combination=False, | ||
product_id=False, | ||
add_qty=1, | ||
pricelist=False, | ||
parent_combination=False, | ||
only_template=False, | ||
): | ||
if ( | ||
pricelist | ||
and pricelist.discount_policy == "without_discount" | ||
and self.env.context.get("website_id") | ||
): | ||
# Compute original price | ||
pricelist = pricelist.with_context(skip_alternative_pricelist=True) | ||
combination_info = super(ProductTemplate, self)._get_combination_info( | ||
combination, | ||
product_id, | ||
add_qty, | ||
pricelist, | ||
parent_combination, | ||
only_template, | ||
) | ||
combination_info["list_price"] = combination_info["price"] | ||
combination_info["base_price"] = combination_info["price"] | ||
# Compute alternative price | ||
pricelist = pricelist.with_context(skip_alternative_pricelist=False) | ||
product = self.env["product.product"].browse(combination_info["product_id"]) | ||
combination_info["price"] = pricelist._get_product_price( | ||
product, quantity=self.env.context.get("quantity", add_qty) | ||
) | ||
combination_info["has_discounted_price"] = ( | ||
combination_info["price"] < combination_info["list_price"] | ||
) | ||
return combination_info | ||
return super()._get_combination_info( | ||
combination, | ||
product_id, | ||
add_qty, | ||
pricelist, | ||
parent_combination, | ||
only_template, | ||
) |
1 change: 1 addition & 0 deletions
1
website_sale_product_pricelist_alternative/readme/CONTRIBUTORS.rst
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 @@ | ||
* Telmo Santos <[email protected]> |
1 change: 1 addition & 0 deletions
1
website_sale_product_pricelist_alternative/readme/DESCRIPTION.rst
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 @@ | ||
Based on `product_pricelist_alternative` (https://github.com/OCA/product-attribute/tree/16.0/product_pricelist_alternative), it allows you to show in the website alternative vs original product prices. |
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,2 @@ | ||
In product pricelist select discount policy as `Show public price and discount to the customer`. | ||
In the pricelist used in the website, you can set the alternative pricelist with the discounted price. |
Oops, something went wrong.