-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] shopinvader_search_engine_product_multi_price
- Loading branch information
Showing
19 changed files
with
703 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...arch_engine_product_multi_price/odoo/addons/shopinvader_search_engine_product_multi_price
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 @@ | ||
../../../../shopinvader_search_engine_product_multi_price |
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,71 @@ | ||
============================================= | ||
Shopinvader Search Engine Product Multi Price | ||
============================================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:05a73ae4cb7fb4ac83a7800fcb3c61a917f562b886794ae028384f1e1675f201 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Alpha | ||
.. |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-shopinvader%2Fodoo--shopinvader-lightgray.png?logo=github | ||
:target: https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_search_engine_product_multi_price | ||
:alt: shopinvader/odoo-shopinvader | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
Adds prices to the export of products for Shopinvader. | ||
One price is exported per pricelist set on the index. | ||
|
||
.. IMPORTANT:: | ||
This is an alpha version, the data model and design can change at any time without warning. | ||
Only for development or testing purpose, do not use in production. | ||
`More details on development status <https://odoo-community.org/page/development-status>`_ | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
Set pricelists per index or on the search engine backend to apply globally. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/shopinvader/odoo-shopinvader/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/shopinvader/odoo-shopinvader/issues/new?body=module:%20shopinvader_search_engine_product_multi_price%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 | ||
~~~~~~~ | ||
|
||
* ACSONE SA/NV | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Quentin Groulard <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `shopinvader/odoo-shopinvader <https://github.com/shopinvader/odoo-shopinvader/tree/16.0/shopinvader_search_engine_product_multi_price>`_ 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,2 @@ | ||
from . import models | ||
from . import schemas |
16 changes: 16 additions & 0 deletions
16
shopinvader_search_engine_product_multi_price/__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,16 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Shopinvader Search Engine Product Multi Price", | ||
"summary": "Add the export of multiple prices for Shopinvader", | ||
"version": "16.0.1.0.0", | ||
"category": "e-commerce", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV", | ||
"website": "https://github.com/shopinvader/odoo-shopinvader", | ||
"depends": ["product_get_price_helper", "shopinvader_search_engine"], | ||
"data": ["views/se_backend.xml", "views/se_index.xml"], | ||
"demo": [], | ||
"development_status": "Alpha", | ||
} |
3 changes: 3 additions & 0 deletions
3
shopinvader_search_engine_product_multi_price/models/__init__.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,3 @@ | ||
from . import product_product | ||
from . import se_backend | ||
from . import se_index |
24 changes: 24 additions & 0 deletions
24
shopinvader_search_engine_product_multi_price/models/product_product.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,24 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
shopinvader_price_by_pricelist = fields.Json( | ||
compute="_compute_shopinvader_price_by_pricelist" | ||
) | ||
|
||
@api.depends_context("index_id") | ||
def _compute_shopinvader_price_by_pricelist(self): | ||
index_id = self.env.context.get("index_id", False) | ||
index = self.env["se.index"].browse(index_id) | ||
for product in self: | ||
prices = {} | ||
if index_id: | ||
for pricelist in index._get_pricelists(): | ||
price = product._get_price(pricelist=pricelist) | ||
prices.update({pricelist.id: price}) | ||
product.shopinvader_price_by_pricelist = prices |
11 changes: 11 additions & 0 deletions
11
shopinvader_search_engine_product_multi_price/models/se_backend.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 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SeBackend(models.Model): | ||
|
||
_inherit = "se.backend" | ||
|
||
pricelist_ids = fields.Many2many("product.pricelist", string="Pricelists") |
20 changes: 20 additions & 0 deletions
20
shopinvader_search_engine_product_multi_price/models/se_index.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 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SeIndex(models.Model): | ||
|
||
_inherit = "se.index" | ||
|
||
pricelist_ids = fields.Many2many( | ||
comodel_name="product.pricelist", | ||
string="Pricelists", | ||
help="Define pricelists for price computation, " | ||
"keep empty to take configuration from the backend", | ||
) | ||
|
||
def _get_pricelists(self): | ||
self.ensure_one() | ||
return self.pricelist_ids or self.backend_id.pricelist_ids |
1 change: 1 addition & 0 deletions
1
shopinvader_search_engine_product_multi_price/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 @@ | ||
* Quentin Groulard <[email protected]> |
2 changes: 2 additions & 0 deletions
2
shopinvader_search_engine_product_multi_price/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,2 @@ | ||
Adds prices to the export of products for Shopinvader. | ||
One price is exported per pricelist set on the index. |
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 @@ | ||
Set pricelists per index or on the search engine backend to apply globally. |
1 change: 1 addition & 0 deletions
1
shopinvader_search_engine_product_multi_price/schemas/__init__.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 @@ | ||
from .product import ProductPriceInfo, ProductProduct |
23 changes: 23 additions & 0 deletions
23
shopinvader_search_engine_product_multi_price/schemas/product.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,23 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from extendable_pydantic import StrictExtendableBaseModel | ||
|
||
from odoo.addons.shopinvader_product.schemas import ProductProduct as BaseProduct | ||
|
||
|
||
class ProductPriceInfo(StrictExtendableBaseModel): | ||
value: float = 0 | ||
tax_included: bool = False | ||
original_value: float = 0 | ||
discount: float = 0 | ||
|
||
|
||
class ProductProduct(BaseProduct, extends=True): | ||
price_by_pricelist: dict[int, ProductPriceInfo] = {} | ||
|
||
@classmethod | ||
def from_product_product(cls, odoo_rec): | ||
obj = super().from_product_product(odoo_rec) | ||
obj.price_by_pricelist = odoo_rec.shopinvader_price_by_pricelist or {} | ||
return obj |
Oops, something went wrong.