diff --git a/product_pricelist_supplierinfo/README.rst b/product_pricelist_supplierinfo/README.rst index 041be8de661..892102ccc0c 100644 --- a/product_pricelist_supplierinfo/README.rst +++ b/product_pricelist_supplierinfo/README.rst @@ -17,13 +17,13 @@ Supplier info prices in sales pricelists :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github - :target: https://github.com/OCA/product-attribute/tree/17.0/product_pricelist_supplierinfo + :target: https://github.com/OCA/product-attribute/tree/18.0/product_pricelist_supplierinfo :alt: OCA/product-attribute .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_pricelist_supplierinfo + :target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_pricelist_supplierinfo :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -102,7 +102,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -152,6 +152,6 @@ Current `maintainer `__: |maintainer-luisg123v| -This module is part of the `OCA/product-attribute `_ project on GitHub. +This module is part of the `OCA/product-attribute `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_pricelist_supplierinfo/__manifest__.py b/product_pricelist_supplierinfo/__manifest__.py index b036ae070c8..681768e2529 100644 --- a/product_pricelist_supplierinfo/__manifest__.py +++ b/product_pricelist_supplierinfo/__manifest__.py @@ -4,7 +4,7 @@ { "name": "Supplier info prices in sales pricelists", "summary": "Allows to create priceslists based on supplier info", - "version": "17.0.2.0.0", + "version": "18.0.1.0.0", "category": "Sales/Sales", "website": "https://github.com/OCA/product-attribute", "author": "Tecnativa, Odoo Community Association (OCA), Vauxoo", diff --git a/product_pricelist_supplierinfo/models/product_template.py b/product_pricelist_supplierinfo/models/product_template.py index 32c7dd91c10..bd389cd1cea 100644 --- a/product_pricelist_supplierinfo/models/product_template.py +++ b/product_pricelist_supplierinfo/models/product_template.py @@ -27,7 +27,7 @@ def _get_supplierinfo_pricelist_price( # The product_variant_id returns empty recordset if template is not # active, so we must ensure variant exists or _select_seller fails. if product: - if type(date) == datetime: + if isinstance(date, datetime): date = date.date() seller = product.with_context( override_min_qty=rule.no_supplierinfo_min_quantity diff --git a/product_pricelist_supplierinfo/static/description/index.html b/product_pricelist_supplierinfo/static/description/index.html index 15344fe2044..1754eaeab8e 100644 --- a/product_pricelist_supplierinfo/static/description/index.html +++ b/product_pricelist_supplierinfo/static/description/index.html @@ -369,7 +369,7 @@

Supplier info prices in sales pricelists

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:3b1eaa22384d0573346866a317e714b3d95555e79eaf6a24283febb60d1e7e16 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

This module allows you to create a sales pricelist based on product supplierinfo prices. If you want, you can bypass minimum quantity in pricelist item.

@@ -451,7 +451,7 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -491,7 +491,7 @@

Maintainers

promote its widespread use.

Current maintainer:

luisg123v

-

This module is part of the OCA/product-attribute project on GitHub.

+

This module is part of the OCA/product-attribute project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/product_pricelist_supplierinfo/tests/test_product_supplierinfo.py b/product_pricelist_supplierinfo/tests/test_product_supplierinfo.py index 1aec56a3737..1c8644000c0 100644 --- a/product_pricelist_supplierinfo/tests/test_product_supplierinfo.py +++ b/product_pricelist_supplierinfo/tests/test_product_supplierinfo.py @@ -60,20 +60,18 @@ def setUpClass(cls): ) @classmethod - def _update_rate(cls, currency_id, rate): - currency_rate = cls.currency_rate_obj.search( - [("name", "=", date.today()), ("currency_id", "=", currency_id.id)], limit=1 - ) - if not currency_rate: - cls.currency_rate_obj.create( - { - "currency_id": currency_id.id, - "rate": rate, - "name": date.today(), - } - ) - else: - currency_rate.write({"rate": rate}) + def _create_rate(cls, currency, rate): + currency_rates = cls.currency_rate_obj.search( + [("name", "=", date.today()), ("currency_id", "=", currency.id)] + ) + currency_rates.unlink() + cls.currency_rate_obj.create( + { + "currency_id": currency.id, + "rate": rate, + "name": date.today(), + } + ) def test_pricelist_based_on_product_category(self): self.pricelist.item_ids[0].write( @@ -259,8 +257,8 @@ def test_pricelist_and_supplierinfo_currencies(self): # and pricelist with different currencies currency_usd = self.env.ref("base.USD") currency_mxn = self.env.ref("base.MXN") - self._update_rate(currency_usd, 1) - self._update_rate(currency_mxn, 20) + self._create_rate(currency_usd, 1) + self._create_rate(currency_mxn, 20) # Setting the item with the product self.pricelist.item_ids[0].write( @@ -327,3 +325,24 @@ def test_pricelist_exclude_supplier_info_discount(self): self.pricelist._get_product_price(self.product, 1), 10, ) + + def test_pricelist_price_not_based_on_supplierinfo(self): + """Test the scenario where the pricelist is not based on the supplier info, + so the price should be calculated as expected natively. + """ + self.pricelist.item_ids[0].base = "list_price" + product_template = self.product.product_tmpl_id + expected_price = product_template._price_compute("list_price") + self.assertAlmostEqual( + self.pricelist._get_product_price(self.product, 1), + expected_price[product_template.id], + ) + + def test_pricelist_price_no_sellers(self): + """Test scenario where there are no sellers linked to the product.""" + product_template = self.product.product_tmpl_id + self.product.seller_ids = False + price = product_template._get_supplierinfo_pricelist_price( + self.pricelist.item_ids[0] + ) + self.assertAlmostEqual(price, 0)