Skip to content

Commit

Permalink
[11.0][NEW] website_sale_product_minimal_price: New module (OCA#283)
Browse files Browse the repository at this point in the history
* [11.0][NEW] website_sale_product_minimal_price: New module

* [11.0][IMP] website_sale_product_minimal_price: Order by minimal variant price (from pricelists or extra variant price)

[UPD] Update website_sale_product_minimal_price.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: e-commerce-11.0/e-commerce-11.0-website_sale_product_minimal_price
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-11-0/e-commerce-11-0-website_sale_product_minimal_price/

[UPD] README.rst
  • Loading branch information
sergio-teruel authored and Pablocce committed Feb 20, 2024
1 parent 7681fc1 commit bbd4ecf
Show file tree
Hide file tree
Showing 18 changed files with 846 additions and 0 deletions.
87 changes: 87 additions & 0 deletions website_sale_product_minimal_price/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==================================
Website Sale Product Minimal Price
==================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/11.0/website_sale_product_minimal_price
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-11-0/e-commerce-11-0-website_sale_product_minimal_price
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/113/11.0
:alt: Try me on Runbot

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

This module extends the functionality of website sale module to allow to
display the minimal price in '/shop' view when product has distinct variants
price and set order by minimal price in product's view.

**Table of contents**

.. contents::
:local:

Usage
=====

#. Go to backend and set a product with variants and extra price by attribute
value or define a distinct prices in public price list for this variant.
#. Go to Website Shop.
#. You will see that in main products view appears the text "From " with
minimal price if the product has a distinct prices by attribute.
#. Click on product, the price displayed is the minimal variant price.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/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/e-commerce/issues/new?body=module:%20website_sale_product_minimal_price%0Aversion:%2011.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>`_:

* Sergio Teruel <sergio.teruel@tecnativa.com>

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/e-commerce <https://github.com/OCA/e-commerce/tree/11.0/website_sale_product_minimal_price>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_sale_product_minimal_price/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models
24 changes: 24 additions & 0 deletions website_sale_product_minimal_price/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': 'Website Sale Product Minimal Price',
'summary': 'Display minimal price for products that has variants',
'version': '11.0.1.0.0',
'development_status': 'Beta',
'category': 'Website',
'website': 'https://github.com/OCA/e-commerce',
'author': 'Tecnativa, Odoo Community Association (OCA)',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': [
'website_sale',
],
'data': [
'views/assets.xml',
'views/templates.xml',
],
'demo': [
'data/demo.xml',
],
}
49 changes: 49 additions & 0 deletions website_sale_product_minimal_price/data/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="product_attribute_test" model="product.attribute">
<!-- For compatibility with tests website_sale_product_attribute_filter_visibility module-->
<field name="website_published" eval="True"/>
<field name="name">Test attribute</field>
<field name="create_variant" eval="True"/>
</record>
<record id="product_attribute_value_test_1" model="product.attribute.value">
<field name="name">Test v1</field>
<field name="attribute_id" ref="product_attribute_test"/>
</record>
<record id="product_attribute_value_test_2" model="product.attribute.value">
<field name="name">Test v2</field>
<field name="attribute_id" ref="product_attribute_test"/>
</record>
<record id="product_product_test_1" model="product.product">
<field name="name">My product test with various prices</field>
<field name="list_price">20.0</field>
<field name="type">consu</field>
<field name="website_published" eval="True"/>
<field name="attribute_value_ids"
eval="[(6, 0, [ref('website_sale_product_minimal_price.product_attribute_value_test_1')])]"/>
</record>
<record id="product_product_test_2" model="product.product">
<field name="product_tmpl_id" ref="product_product_test_1_product_template"/>
<field name="attribute_value_ids" eval="[(6, 0, [ref('website_sale_product_minimal_price.product_attribute_value_test_2')])]"/>
</record>
<record id="product_attribute_line_test" model="product.attribute.line">
<field name="product_tmpl_id" ref="product_product_test_1_product_template"/>
<field name="attribute_id" ref="product_attribute_test"/>
<field name="value_ids" eval="[(6, 0, [ref('website_sale_product_minimal_price.product_attribute_value_test_1'), ref('website_sale_product_minimal_price.product_attribute_value_test_2')])]"/>
</record>
<record id="product_product_test_1_product_template" model="product.template">
<field name="attribute_line_ids" eval="[(6, 0, [ref('website_sale_product_minimal_price.product_attribute_line_test')])]"/>
</record>
<record id="product_attribute_price_test_1" model="product.attribute.price">
<field name="product_tmpl_id" ref="product_product_test_1_product_template"/>
<field name="value_id" ref="product_attribute_value_test_1"/>
<field name="price_extra">5.0</field>
</record>
<record id="product_attribute_price_test_2" model="product.attribute.price">
<field name="product_tmpl_id" ref="product_product_test_1_product_template"/>
<field name="value_id" ref="product_attribute_value_test_2"/>
<field name="price_extra">10.0</field>
</record>

</odoo>
57 changes: 57 additions & 0 deletions website_sale_product_minimal_price/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_minimal_price
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-07 14:11+0000\n"
"PO-Revision-Date: 2019-05-07 16:13+0200\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: 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 2.0.6\n"

#. module: website_sale_product_minimal_price
#: model:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "<span>From </span>"
msgstr "<span>Desde </span>"

#. module: website_sale_product_minimal_price
#: model:ir.model.fields,field_description:website_sale_product_minimal_price.field_product_product_has_distinct_variant_price
#: model:ir.model.fields,field_description:website_sale_product_minimal_price.field_product_template_has_distinct_variant_price
msgid "Has variants with distinct extra"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:product.product,name:website_sale_product_minimal_price.product_product_test_1
#: model:product.product,name:website_sale_product_minimal_price.product_product_test_2
#: model:product.template,name:website_sale_product_minimal_price.product_product_test_1_product_template
#: model:product.template,name:website_sale_product_minimal_price.product_product_test_2_product_template
msgid "My product test with various prices"
msgstr "Mi producto de test con varios precios"

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: website_sale_product_minimal_price
#: model:product.attribute,name:website_sale_product_minimal_price.product_attribute_test
msgid "Test attribute"
msgstr "Atributo de prueba"

#. module: website_sale_product_minimal_price
#: model:product.attribute.value,name:website_sale_product_minimal_price.product_attribute_value_test_1
msgid "Test v1"
msgstr "Valor 1 de test"

#. module: website_sale_product_minimal_price
#: model:product.attribute.value,name:website_sale_product_minimal_price.product_attribute_value_test_2
msgid "Test v2"
msgstr "Valor 2 de test"
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_product_minimal_price
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.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_product_minimal_price
#: model:ir.ui.view,arch_db:website_sale_product_minimal_price.products_item
msgid "<span>From </span>"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:ir.model.fields,field_description:website_sale_product_minimal_price.field_product_product_has_distinct_variant_price
#: model:ir.model.fields,field_description:website_sale_product_minimal_price.field_product_template_has_distinct_variant_price
msgid "Has variants with distinct extra"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:product.product,name:website_sale_product_minimal_price.product_product_test_1
#: model:product.product,name:website_sale_product_minimal_price.product_product_test_2
#: model:product.template,name:website_sale_product_minimal_price.product_product_test_1_product_template
#: model:product.template,name:website_sale_product_minimal_price.product_product_test_2_product_template
msgid "My product test with various prices"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:ir.model,name:website_sale_product_minimal_price.model_product_template
msgid "Product Template"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:product.attribute,name:website_sale_product_minimal_price.product_attribute_test
msgid "Test attribute"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:product.attribute.value,name:website_sale_product_minimal_price.product_attribute_value_test_1
msgid "Test v1"
msgstr ""

#. module: website_sale_product_minimal_price
#: model:product.attribute.value,name:website_sale_product_minimal_price.product_attribute_value_test_2
msgid "Test v2"
msgstr ""

1 change: 1 addition & 0 deletions website_sale_product_minimal_price/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_template
29 changes: 29 additions & 0 deletions website_sale_product_minimal_price/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import fields, models


class ProductTemplate(models.Model):
_inherit = 'product.template'

has_distinct_variant_price = fields.Boolean(
compute='_compute_has_distinct_variant_price',
string='Has variants with distinct extra',
)

def _compute_has_distinct_variant_price(self):
for template in self:
if template.product_variant_count > 1:
prices = template.product_variant_ids.mapped('website_price')
if len(prices) > 1:
template.has_distinct_variant_price = True

def _website_price(self):
templates = self.filtered(lambda x: x.product_variant_count > 1)
super(ProductTemplate, self - templates)._website_price()
for product in templates:
variant = product.product_variant_ids.sorted(
key=lambda p: p.website_price)[:1]
product.website_price = variant.website_price
product.website_public_price = variant.website_public_price
product.website_price_difference = variant.website_price_difference
3 changes: 3 additions & 0 deletions website_sale_product_minimal_price/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel <sergio.teruel@tecnativa.com>
3 changes: 3 additions & 0 deletions website_sale_product_minimal_price/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module extends the functionality of website sale module to allow to
display the minimal price in '/shop' view when product has distinct variants
price and set order by minimal price in product's view.
6 changes: 6 additions & 0 deletions website_sale_product_minimal_price/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#. Go to backend and set a product with variants and extra price by attribute
value or define a distinct prices in public price list for this variant.
#. Go to Website Shop.
#. You will see that in main products view appears the text "From " with
minimal price if the product has a distinct prices by attribute.
#. Click on product, the price displayed is the minimal variant price.
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 bbd4ecf

Please sign in to comment.