diff --git a/website_sale_stock_available/README.rst b/website_sale_stock_available/README.rst new file mode 100644 index 0000000..9c207b7 --- /dev/null +++ b/website_sale_stock_available/README.rst @@ -0,0 +1,127 @@ +============================ +Website Sale Stock Available +============================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/website_sale_stock_available + :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-12-0/e-commerce-12-0-website_sale_stock_available + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of 'Product Availability' module +(Technical name: website_sale_stock) so that for the 'Website shop' the +'Available' quantity of a product is taken into account instead of +'Forecasted' quantity. + +This image shows where you can see those quantities: + +.. image:: https://raw.githubusercontent.com/OCA/e-commerce/12.0/website_sale_stock_available/static/description/product_quantities.png + :width: 600 px + :alt: Product quantities + +| + +If a product is configured to 'prevent sales if not enough stock' +(see configuration section) and its page is accessed in the Website Shop, +the availability messages will be based on the 'Available' quantity instead of +'Forecasted' quantity. And also, the Website shop wont allow you to buy more +products than 'Available' quantity (not 'Forecasted' quantity is taken +into account). + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +To configure this module, you need to: + +#. Go to *Inventory > Master Data > Products* and edit a product that + you only want to sell in the website shop if there is enough stock. +#. Navigate to 'Availability' field in the 'eCommerce' tab and set + one of these options: + + * Show inventory on website and prevent sales if not enough stock + * Show inventory below a threshold and prevent sales if not enough stock. +#. Go to *Inventory > Configuration > Settings*, navigate to *Stock available + to promise* section and set the desired option. If you do not choose any, + the value of 'Available' quantity will be equal to 'Forecasted' quantity. + +Usage +===== + +To use this module, you need to: + +#. Go to your Website shop. +#. Select a product that you has previously configured to 'prevent sales + if not enough stock' for the web product page. +#. Odoo doesn't allow you to add the product to the car if 'Available' + quantity (not 'Forecasted' quantity) is equal or less than zero. + Besides, availability messages will be based on the 'Available' + quantity instead of the 'Forecasted' quantity. + +.. image:: https://raw.githubusercontent.com/OCA/e-commerce/12.0/website_sale_stock_available/static/description/availability_message.png + :width: 600 px + :alt: Availability message + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Ernesto Tejeda + * Pedro M. Baeza + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_stock_available/__init__.py b/website_sale_stock_available/__init__.py new file mode 100644 index 0000000..df9b9c2 --- /dev/null +++ b/website_sale_stock_available/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import controllers +from . import models diff --git a/website_sale_stock_available/__manifest__.py b/website_sale_stock_available/__manifest__.py new file mode 100644 index 0000000..25e543f --- /dev/null +++ b/website_sale_stock_available/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Website Sale Stock Available", + "summary": "Display 'Available to promise' in shop online " + "instead 'Quantity On Hand'", + "version": "12.0.1.0.3", + "category": "Website", + "website": "https://github.com/OCA/e-commerce", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "stock_available", + "website_sale_stock", + ], + "data": [ + ], + "installable": True, +} diff --git a/website_sale_stock_available/controllers/__init__.py b/website_sale_stock_available/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/website_sale_stock_available/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_sale_stock_available/controllers/main.py b/website_sale_stock_available/controllers/main.py new file mode 100644 index 0000000..5cb3325 --- /dev/null +++ b/website_sale_stock_available/controllers/main.py @@ -0,0 +1,14 @@ +# Copyright 2020 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from odoo.addons.website_sale_stock.controllers.main import WebsiteSale +from odoo.http import request, route + + +class WebsiteSale(WebsiteSale): + + @route() + def payment_transaction(self, *args, **kwargs): + """Inject a context when potencial or promised stock is set""" + request.website = request.website.with_context( + website_sale_stock_available=True) + return super().payment_transaction(*args, **kwargs) diff --git a/website_sale_stock_available/i18n/ca.po b/website_sale_stock_available/i18n/ca.po new file mode 100644 index 0000000..7a7ba18 --- /dev/null +++ b/website_sale_stock_available/i18n/ca.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-20 20:45+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_product +msgid "Product" +msgstr "Producte" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_template +msgid "Product Template" +msgstr "Plantilla de producte" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_sale_order +msgid "Sale Order" +msgstr "Comanda de venda" diff --git a/website_sale_stock_available/i18n/es.po b/website_sale_stock_available/i18n/es.po new file mode 100644 index 0000000..92cd693 --- /dev/null +++ b/website_sale_stock_available/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-11-03 13:08+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_product +msgid "Product" +msgstr "Producto" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_sale_order +msgid "Sale Order" +msgstr "Pedido de venta" diff --git a/website_sale_stock_available/i18n/es_CL.po b/website_sale_stock_available/i18n/es_CL.po new file mode 100644 index 0000000..47fc52f --- /dev/null +++ b/website_sale_stock_available/i18n/es_CL.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-05-30 05:19+0000\n" +"Last-Translator: Nelson Ramírez Sánchez \n" +"Language-Team: none\n" +"Language: es_CL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_product +msgid "Product" +msgstr "Producto" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_template +msgid "Product Template" +msgstr "Plantilla de Producto" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_sale_order +msgid "Sale Order" +msgstr "Nota de Venta" diff --git a/website_sale_stock_available/i18n/fr.po b/website_sale_stock_available/i18n/fr.po new file mode 100644 index 0000000..2ec0b67 --- /dev/null +++ b/website_sale_stock_available/i18n/fr.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-11-23 15:36+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_product +msgid "Product" +msgstr "Article" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_sale_order +msgid "Sale Order" +msgstr "Commande client" diff --git a/website_sale_stock_available/i18n/nl.po b/website_sale_stock_available/i18n/nl.po new file mode 100644 index 0000000..9027210 --- /dev/null +++ b/website_sale_stock_available/i18n/nl.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-12-15 13:19+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_product +msgid "Product" +msgstr "Product" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_product_template +msgid "Product Template" +msgstr "Product Sjabloon" + +#. module: website_sale_stock_available +#: model:ir.model,name:website_sale_stock_available.model_sale_order +msgid "Sale Order" +msgstr "Verkoop order" diff --git a/website_sale_stock_available/models/__init__.py b/website_sale_stock_available/models/__init__.py new file mode 100644 index 0000000..5486cb6 --- /dev/null +++ b/website_sale_stock_available/models/__init__.py @@ -0,0 +1,5 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import product_product +from . import product_template +from . import sale_order diff --git a/website_sale_stock_available/models/product_product.py b/website_sale_stock_available/models/product_product.py new file mode 100644 index 0000000..45fe063 --- /dev/null +++ b/website_sale_stock_available/models/product_product.py @@ -0,0 +1,19 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class Product(models.Model): + _inherit = 'product.product' + + def _compute_quantities_dict(self, lot_id, owner_id, package_id, + from_date=False, to_date=False): + res = super()._compute_quantities_dict( + lot_id, owner_id, package_id, from_date, to_date) + if self.env.context.get('website_sale_stock_available'): + for product in self.with_context( + website_sale_stock_available=False): + immediately = product.immediately_usable_qty + res[product.id]['virtual_available'] = immediately + return res diff --git a/website_sale_stock_available/models/product_template.py b/website_sale_stock_available/models/product_template.py new file mode 100644 index 0000000..7d052a7 --- /dev/null +++ b/website_sale_stock_available/models/product_template.py @@ -0,0 +1,17 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models, api + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + @api.multi + def _get_combination_info(self, combination=False, product_id=False, + add_qty=1, pricelist=False, + parent_combination=False, only_template=False): + template = self.with_context(website_sale_stock_available=True) + return super(ProductTemplate, template)._get_combination_info( + combination, product_id, add_qty, pricelist, parent_combination, + only_template) diff --git a/website_sale_stock_available/models/sale_order.py b/website_sale_stock_available/models/sale_order.py new file mode 100644 index 0000000..76d20b6 --- /dev/null +++ b/website_sale_stock_available/models/sale_order.py @@ -0,0 +1,15 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + @api.multi + def _cart_update(self, product_id=None, line_id=None, add_qty=0, + set_qty=0, **kwargs): + order = self.with_context(website_sale_stock_available=True) + return super(SaleOrder, order)._cart_update( + product_id, line_id, add_qty, set_qty, **kwargs) diff --git a/website_sale_stock_available/readme/CONFIGURE.rst b/website_sale_stock_available/readme/CONFIGURE.rst new file mode 100644 index 0000000..5de4f57 --- /dev/null +++ b/website_sale_stock_available/readme/CONFIGURE.rst @@ -0,0 +1,12 @@ +To configure this module, you need to: + +#. Go to *Inventory > Master Data > Products* and edit a product that + you only want to sell in the website shop if there is enough stock. +#. Navigate to 'Availability' field in the 'eCommerce' tab and set + one of these options: + + * Show inventory on website and prevent sales if not enough stock + * Show inventory below a threshold and prevent sales if not enough stock. +#. Go to *Inventory > Configuration > Settings*, navigate to *Stock available + to promise* section and set the desired option. If you do not choose any, + the value of 'Available' quantity will be equal to 'Forecasted' quantity. diff --git a/website_sale_stock_available/readme/CONTRIBUTORS.rst b/website_sale_stock_available/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..b31cef3 --- /dev/null +++ b/website_sale_stock_available/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* `Tecnativa `_: + + * Ernesto Tejeda + * Pedro M. Baeza diff --git a/website_sale_stock_available/readme/DESCRIPTION.rst b/website_sale_stock_available/readme/DESCRIPTION.rst new file mode 100644 index 0000000..aebdc49 --- /dev/null +++ b/website_sale_stock_available/readme/DESCRIPTION.rst @@ -0,0 +1,19 @@ +This module extends the functionality of 'Product Availability' module +(Technical name: website_sale_stock) so that for the 'Website shop' the +'Available' quantity of a product is taken into account instead of +'Forecasted' quantity. + +This image shows where you can see those quantities: + +.. image:: ../static/description/product_quantities.png + :width: 600 px + :alt: Product quantities + +| + +If a product is configured to 'prevent sales if not enough stock' +(see configuration section) and its page is accessed in the Website Shop, +the availability messages will be based on the 'Available' quantity instead of +'Forecasted' quantity. And also, the Website shop wont allow you to buy more +products than 'Available' quantity (not 'Forecasted' quantity is taken +into account). diff --git a/website_sale_stock_available/readme/USAGE.rst b/website_sale_stock_available/readme/USAGE.rst new file mode 100644 index 0000000..0da1efd --- /dev/null +++ b/website_sale_stock_available/readme/USAGE.rst @@ -0,0 +1,13 @@ +To use this module, you need to: + +#. Go to your Website shop. +#. Select a product that you has previously configured to 'prevent sales + if not enough stock' for the web product page. +#. Odoo doesn't allow you to add the product to the car if 'Available' + quantity (not 'Forecasted' quantity) is equal or less than zero. + Besides, availability messages will be based on the 'Available' + quantity instead of the 'Forecasted' quantity. + +.. image:: ../static/description/availability_message.png + :width: 600 px + :alt: Availability message diff --git a/website_sale_stock_available/static/description/availability_message.png b/website_sale_stock_available/static/description/availability_message.png new file mode 100644 index 0000000..e556d64 Binary files /dev/null and b/website_sale_stock_available/static/description/availability_message.png differ diff --git a/website_sale_stock_available/static/description/icon.png b/website_sale_stock_available/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/website_sale_stock_available/static/description/icon.png differ diff --git a/website_sale_stock_available/static/description/index.html b/website_sale_stock_available/static/description/index.html new file mode 100644 index 0000000..7c1b1b8 --- /dev/null +++ b/website_sale_stock_available/static/description/index.html @@ -0,0 +1,470 @@ + + + + + + +Website Sale Stock Available + + + +
+

Website Sale Stock Available

+ + +

Beta License: AGPL-3 OCA/e-commerce Translate me on Weblate Try me on Runbot

+

This module extends the functionality of ‘Product Availability’ module +(Technical name: website_sale_stock) so that for the ‘Website shop’ the +‘Available’ quantity of a product is taken into account instead of +‘Forecasted’ quantity.

+

This image shows where you can see those quantities:

+Product quantities +
+

+
+

If a product is configured to ‘prevent sales if not enough stock’ +(see configuration section) and its page is accessed in the Website Shop, +the availability messages will be based on the ‘Available’ quantity instead of +‘Forecasted’ quantity. And also, the Website shop wont allow you to buy more +products than ‘Available’ quantity (not ‘Forecasted’ quantity is taken +into account).

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Inventory > Master Data > Products and edit a product that +you only want to sell in the website shop if there is enough stock.
  2. +
  3. Navigate to ‘Availability’ field in the ‘eCommerce’ tab and set +one of these options:
      +
    • Show inventory on website and prevent sales if not enough stock
    • +
    • Show inventory below a threshold and prevent sales if not enough stock.
    • +
    +
  4. +
  5. Go to Inventory > Configuration > Settings, navigate to Stock available +to promise section and set the desired option. If you do not choose any, +the value of ‘Available’ quantity will be equal to ‘Forecasted’ quantity.
  6. +
+
+
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to your Website shop.
  2. +
  3. Select a product that you has previously configured to ‘prevent sales +if not enough stock’ for the web product page.
  4. +
  5. Odoo doesn’t allow you to add the product to the car if ‘Available’ +quantity (not ‘Forecasted’ quantity) is equal or less than zero. +Besides, availability messages will be based on the ‘Available’ +quantity instead of the ‘Forecasted’ quantity.
  6. +
+Availability message +
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Ernesto Tejeda
    • +
    • Pedro M. Baeza
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

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

+
+
+
+ + diff --git a/website_sale_stock_available/static/description/product_quantities.png b/website_sale_stock_available/static/description/product_quantities.png new file mode 100644 index 0000000..8445154 Binary files /dev/null and b/website_sale_stock_available/static/description/product_quantities.png differ diff --git a/website_sale_stock_available/tests/__init__.py b/website_sale_stock_available/tests/__init__.py new file mode 100644 index 0000000..59a5546 --- /dev/null +++ b/website_sale_stock_available/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import test_website_sale_stock_available diff --git a/website_sale_stock_available/tests/test_website_sale_stock_available.py b/website_sale_stock_available/tests/test_website_sale_stock_available.py new file mode 100644 index 0000000..d87d7ff --- /dev/null +++ b/website_sale_stock_available/tests/test_website_sale_stock_available.py @@ -0,0 +1,73 @@ +# Copyright 2020 Tecnativa - Ernesto Tejeda +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import SavepointCase + + +class SaleStockAvailableInfoPopup(SavepointCase): + + @classmethod + def setUpClass(cls): + super(SaleStockAvailableInfoPopup, cls).setUpClass() + user_group_stock_user = cls.env.ref('stock.group_stock_user') + cls.user_stock_user = cls.env['res.users'].create({ + 'name': 'Pauline Poivraisselle', + 'login': 'pauline', + 'email': 'p.p@example.com', + 'notification_type': 'inbox', + 'groups_id': [(6, 0, [user_group_stock_user.id])]}) + cls.product = cls.env['product.product'].create({ + 'name': 'Storable product', + 'type': 'product', + }) + cls.stock_location = cls.env.ref('stock.stock_location_stock') + cls.customers_location = cls.env.ref('stock.stock_location_customers') + cls.suppliers_location = cls.env.ref('stock.stock_location_suppliers') + cls.env['stock.quant'].create({ + 'product_id': cls.product.id, + 'location_id': cls.stock_location.id, + 'quantity': 40.0}) + cls.picking_out = cls.env['stock.picking'].create({ + 'picking_type_id': cls.env.ref('stock.picking_type_out').id, + 'location_id': cls.stock_location.id, + 'location_dest_id': cls.customers_location.id}) + cls.env['stock.move'].create({ + 'name': 'a move', + 'product_id': cls.product.id, + 'product_uom_qty': 3.0, + 'product_uom': cls.product.uom_id.id, + 'picking_id': cls.picking_out.id, + 'location_id': cls.stock_location.id, + 'location_dest_id': cls.customers_location.id}) + cls.picking_in = cls.env['stock.picking'].create({ + 'picking_type_id': cls.env.ref('stock.picking_type_in').id, + 'location_id': cls.suppliers_location.id, + 'location_dest_id': cls.stock_location.id}) + cls.env['stock.move'].create({ + 'restrict_partner_id': cls.user_stock_user.partner_id.id, + 'name': 'another move', + 'product_id': cls.product.id, + 'product_uom_qty': 5.0, + 'product_uom': cls.product.uom_id.id, + 'picking_id': cls.picking_in.id, + 'location_id': cls.suppliers_location.id, + 'location_dest_id': cls.stock_location.id}) + + def test_get_combination_info(self): + product_tmpl = self.product.product_tmpl_id + combination_info = product_tmpl.with_context( + website_sale_stock_get_quantity=True, + )._get_combination_info() + self.assertEqual( + combination_info['virtual_available'], + 40, + ) + self.picking_out.action_confirm() + self.picking_in.action_assign() + combination_info = product_tmpl.with_context( + website_sale_stock_get_quantity=True, + )._get_combination_info() + self.assertEqual( + combination_info['virtual_available'], + self.product.immediately_usable_qty + ) diff --git a/website_sale_stock_available_display/README.rst b/website_sale_stock_available_display/README.rst new file mode 100644 index 0000000..1dd06ca --- /dev/null +++ b/website_sale_stock_available_display/README.rst @@ -0,0 +1,91 @@ +==================================== +Website Sale Stock Available Display +==================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/website_sale_stock_available_display + :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-12-0/e-commerce-12-0-website_sale_stock_available_display + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of website sale stock module to allow to +display available stock in website products and allow to buy if not enough +stock. +Also re-use the field Custom Message for inform to customer of any message +when stock is less than 0.0 units. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +#. Go to *'Sale > Catalog > Product'*. +#. Set *Show inventory on website and allow sales if not enough stock* in + inventory availability field. +#. You can set a custom message that appears when available stock is less than + 0.0 units. +#. Go to Website Shop. +#. Click in any product that you know that no stock available. +#. You will see '*0 units in stock*' but you will buy this product. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `_: + + * Sergio Teruel + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_sale_stock_available_display/__init__.py b/website_sale_stock_available_display/__init__.py new file mode 100644 index 0000000..3275ac2 --- /dev/null +++ b/website_sale_stock_available_display/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/website_sale_stock_available_display/__manifest__.py b/website_sale_stock_available_display/__manifest__.py new file mode 100644 index 0000000..e77d283 --- /dev/null +++ b/website_sale_stock_available_display/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + 'name': 'Website Sale Stock Available Display', + 'summary': 'Display stock in shop online and allow to sell with no stock ' + 'available', + 'version': '12.0.1.2.1', + '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_stock', + ], + 'data': [ + 'views/assets.xml', + 'views/product_template_views.xml', + 'views/templates.xml', + ], +} diff --git a/website_sale_stock_available_display/data/demo.xml b/website_sale_stock_available_display/data/demo.xml new file mode 100644 index 0000000..665ea4b --- /dev/null +++ b/website_sale_stock_available_display/data/demo.xml @@ -0,0 +1,25 @@ + + + + + Computer Motherboard + product + always_no_lock + + Available in 10 days + + + + Special Mouse + product + always_no_lock + + + + + + + 10.0 + + + diff --git a/website_sale_stock_available_display/i18n/ca.po b/website_sale_stock_available_display/i18n/ca.po new file mode 100644 index 0000000..f50eb7c --- /dev/null +++ b/website_sale_stock_available_display/i18n/ca.po @@ -0,0 +1,91 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available_display +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2021-01-20 20:45+0000\n" +"Last-Translator: claudiagn \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_template__inventory_availability +msgid "Adds an inventory availability status on the web product page." +msgstr "" +"Afegeix un estat de disponibilitat d’inventari a la pàgina del producte web." + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Block sales on website and display a message custom" +msgstr "Bloqueja les vendes al lloc web i mostra un missatge personalitzat" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_res_config_settings +msgid "Config Settings" +msgstr "Paràmetres de configuració" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_template__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_res_config_settings__inventory_availability +msgid "Inventory Availability" +msgstr "Disponibilitat d'inventari" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_product_template +msgid "Product Template" +msgstr "Plantilla de producte" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Sell regardless of inventory" +msgstr "Vendre independenment del inventari" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory below a threshold and prevent sales if not enough stock" +msgstr "" +"Mostra l'inventari per sota d'un llindar i evita les vendes si no hi ha prou " +"existències" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and allow sales if not enough stock" +msgstr "" +"Mostra l'inventari al lloc web i permet les vendes si no hi ha prou " +"existències" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and prevent sales if not enough stock" +msgstr "" +"Mostra l'inventari al lloc web i evita les vendes si no hi ha prou " +"existències" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show product-specific notifications" +msgstr "Mostra les notificacions específiques del producte" + +#. module: website_sale_stock_available_display +#. openerp-web +#: code:addons/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml:10 +#: model_terms:ir.ui.view,arch_db:website_sale_stock_available_display.stock_info +#, python-format +msgid "in stock" +msgstr "en estoc" diff --git a/website_sale_stock_available_display/i18n/de.po b/website_sale_stock_available_display/i18n/de.po new file mode 100644 index 0000000..752c7c8 --- /dev/null +++ b/website_sale_stock_available_display/i18n/de.po @@ -0,0 +1,94 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available_display +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-08-11 17:59+0000\n" +"Last-Translator: André Volksdorf \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_template__inventory_availability +msgid "Adds an inventory availability status on the web product page." +msgstr "" +"Fügt einen Bestandsverfügbarkeitsstatus auf der Produktseite der Website " +"hinzu." + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Block sales on website and display a message custom" +msgstr "" +"Verkäufe auf der Website blockieren und eine benutzerdefinierte Nachricht " +"anzeigen" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_res_config_settings +msgid "Config Settings" +msgstr "Konfigurationseinstellungen" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_template__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_res_config_settings__inventory_availability +msgid "Inventory Availability" +msgstr "Verfügbarkeit der Bestände" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_product_template +msgid "Product Template" +msgstr "Produkt-Vorlage" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Sell regardless of inventory" +msgstr "Verkaufen unabhängig vom Bestand" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory below a threshold and prevent sales if not enough stock" +msgstr "" +"Lagerbestand unter einem Schwellenwert anzeigen und Verkäufe verhindern, " +"wenn nicht genügend Bestand vorhanden ist" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and allow sales if not enough stock" +msgstr "" +"Lagerbestand auf der Website anzeigen und Verkäufe zulassen, wenn nicht " +"genug Bestand vorhanden ist" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and prevent sales if not enough stock" +msgstr "" +"Lagerbestand auf der Website anzeigen und Verkäufe verhindern, wenn nicht " +"genügend Bestand vorhanden ist" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show product-specific notifications" +msgstr "Produktspezifische Benachrichtigungen anzeigen" + +#. module: website_sale_stock_available_display +#. openerp-web +#: code:addons/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml:10 +#: model_terms:ir.ui.view,arch_db:website_sale_stock_available_display.stock_info +#, python-format +msgid "in stock" +msgstr "Auf Lager" diff --git a/website_sale_stock_available_display/i18n/es.po b/website_sale_stock_available_display/i18n/es.po new file mode 100644 index 0000000..95d3d51 --- /dev/null +++ b/website_sale_stock_available_display/i18n/es.po @@ -0,0 +1,99 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available_display +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-05-07 21:58+0000\n" +"PO-Revision-Date: 2020-11-03 13:08+0000\n" +"Last-Translator: claudiagn \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: Weblate 3.10\n" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_template__inventory_availability +msgid "Adds an inventory availability status on the web product page." +msgstr "" +"Añade un estado de disponibilidad en inventario en la página web del " +"producto." + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Block sales on website and display a message custom" +msgstr "Bloquear la venta en la tienda y mostrar el mensaje personalizado" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_res_config_settings +msgid "Config Settings" +msgstr "Opciones de Configuración" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_template__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_res_config_settings__inventory_availability +msgid "Inventory Availability" +msgstr "Disponibilidad del inventario" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Sell regardless of inventory" +msgstr "Vender independientemente del inventario" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory below a threshold and prevent sales if not enough stock" +msgstr "" +"Mostrar el inventario por debajo de un determinado umbral y bloquear las " +"ventas si no hay suficientes existencias" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and allow sales if not enough stock" +msgstr "" +"Mostrar el inventario en el sitio web y no bloquear las ventas si no hay \n" +"suficientes existencias" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and prevent sales if not enough stock" +msgstr "" +"Mostrar el inventario en el sitio web y bloquear las ventas si no hay " +"suficientes existencias" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show product-specific notifications" +msgstr "Mostrar notificaciones sobre el producto" + +#. module: website_sale_stock_available_display +#. openerp-web +#: code:addons/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml:10 +#: model_terms:ir.ui.view,arch_db:website_sale_stock_available_display.stock_info +#, python-format +msgid "in stock" +msgstr "en stock" + +#~ msgid "Computer Motherboard" +#~ msgstr "Placa base" + +#~ msgid "Special Mouse" +#~ msgstr "Ratón especial" diff --git a/website_sale_stock_available_display/i18n/fr.po b/website_sale_stock_available_display/i18n/fr.po new file mode 100644 index 0000000..52b853a --- /dev/null +++ b/website_sale_stock_available_display/i18n/fr.po @@ -0,0 +1,91 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available_display +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-11-23 15:36+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_template__inventory_availability +msgid "Adds an inventory availability status on the web product page." +msgstr "Ajoute une information de disponibilité sur la page Web du produit." + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Block sales on website and display a message custom" +msgstr "Bloquer les ventes sur le site Web et afficher un message personnalisé" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_res_config_settings +msgid "Config Settings" +msgstr "Paramètres de config" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_template__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_res_config_settings__inventory_availability +msgid "Inventory Availability" +msgstr "Disponibilité" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Sell regardless of inventory" +msgstr "Vente sans tenir compte du stock" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory below a threshold and prevent sales if not enough stock" +msgstr "" +"Indiquer si l'inventaire est inférieur à un certain seuil et bloquer les " +"ventes en cas de stock insuffisant" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and allow sales if not enough stock" +msgstr "" +"Afficher l'inventaire sur le site Web et autoriser les ventes en cas de " +"stock insuffisant" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and prevent sales if not enough stock" +msgstr "" +"Afficher l'inventaire sur le site Web et bloquer les ventes en cas de stock " +"insuffisant" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show product-specific notifications" +msgstr "" +"Afficher un message de disponibilité personnalisé et spécique au produit" + +#. module: website_sale_stock_available_display +#. openerp-web +#: code:addons/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml:10 +#: model_terms:ir.ui.view,arch_db:website_sale_stock_available_display.stock_info +#, python-format +msgid "in stock" +msgstr "en stock" diff --git a/website_sale_stock_available_display/i18n/nl.po b/website_sale_stock_available_display/i18n/nl.po new file mode 100644 index 0000000..ee62c29 --- /dev/null +++ b/website_sale_stock_available_display/i18n/nl.po @@ -0,0 +1,86 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_sale_stock_available_display +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-12-15 13:19+0000\n" +"Last-Translator: Bosd \n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,help:website_sale_stock_available_display.field_product_template__inventory_availability +msgid "Adds an inventory availability status on the web product page." +msgstr "" +"Voegt een beschikbare voorraad status toe aan de product pagina op de " +"website." + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Block sales on website and display a message custom" +msgstr "Blokkeer verkopen op de website en geef een aangepaste boodschap weer" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: website_sale_stock_available_display +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_product__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_product_template__inventory_availability +#: model:ir.model.fields,field_description:website_sale_stock_available_display.field_res_config_settings__inventory_availability +msgid "Inventory Availability" +msgstr "Beschikbare voorraad" + +#. module: website_sale_stock_available_display +#: model:ir.model,name:website_sale_stock_available_display.model_product_template +msgid "Product Template" +msgstr "Product Sjabloon" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Sell regardless of inventory" +msgstr "Verkoop ongeacht de voorraad" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory below a threshold and prevent sales if not enough stock" +msgstr "" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and allow sales if not enough stock" +msgstr "" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show inventory on website and prevent sales if not enough stock" +msgstr "" + +#. module: website_sale_stock_available_display +#: selection:product.template,inventory_availability:0 +#: selection:res.config.settings,inventory_availability:0 +msgid "Show product-specific notifications" +msgstr "" + +#. module: website_sale_stock_available_display +#. openerp-web +#: code:addons/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml:10 +#: model_terms:ir.ui.view,arch_db:website_sale_stock_available_display.stock_info +#, python-format +msgid "in stock" +msgstr "" diff --git a/website_sale_stock_available_display/models/__init__.py b/website_sale_stock_available_display/models/__init__.py new file mode 100644 index 0000000..1fb0593 --- /dev/null +++ b/website_sale_stock_available_display/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_template +from . import res_config_settings diff --git a/website_sale_stock_available_display/models/product_template.py b/website_sale_stock_available_display/models/product_template.py new file mode 100644 index 0000000..f1f71b5 --- /dev/null +++ b/website_sale_stock_available_display/models/product_template.py @@ -0,0 +1,12 @@ +# 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' + + inventory_availability = fields.Selection(selection_add=[ + ('always_no_lock', + 'Show inventory on website and allow sales if not enough stock'), + ]) diff --git a/website_sale_stock_available_display/models/res_config_settings.py b/website_sale_stock_available_display/models/res_config_settings.py new file mode 100644 index 0000000..62dd46a --- /dev/null +++ b/website_sale_stock_available_display/models/res_config_settings.py @@ -0,0 +1,13 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = 'res.config.settings' + + inventory_availability = fields.Selection(selection_add=[ + ('always_no_lock', + 'Show inventory on website and allow sales if not enough stock'), + ]) diff --git a/website_sale_stock_available_display/readme/CONTRIBUTORS.rst b/website_sale_stock_available_display/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..3bfad99 --- /dev/null +++ b/website_sale_stock_available_display/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `_: + + * Sergio Teruel diff --git a/website_sale_stock_available_display/readme/DESCRIPTION.rst b/website_sale_stock_available_display/readme/DESCRIPTION.rst new file mode 100644 index 0000000..4107522 --- /dev/null +++ b/website_sale_stock_available_display/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module extends the functionality of website sale stock module to allow to +display available stock in website products and allow to buy if not enough +stock. +Also re-use the field Custom Message for inform to customer of any message +when stock is less than 0.0 units. diff --git a/website_sale_stock_available_display/readme/USAGE.rst b/website_sale_stock_available_display/readme/USAGE.rst new file mode 100644 index 0000000..36ff144 --- /dev/null +++ b/website_sale_stock_available_display/readme/USAGE.rst @@ -0,0 +1,8 @@ +#. Go to *'Sale > Catalog > Product'*. +#. Set *Show inventory on website and allow sales if not enough stock* in + inventory availability field. +#. You can set a custom message that appears when available stock is less than + 0.0 units. +#. Go to Website Shop. +#. Click in any product that you know that no stock available. +#. You will see '*0 units in stock*' but you will buy this product. diff --git a/website_sale_stock_available_display/static/description/icon.png b/website_sale_stock_available_display/static/description/icon.png new file mode 100644 index 0000000..3a0328b Binary files /dev/null and b/website_sale_stock_available_display/static/description/icon.png differ diff --git a/website_sale_stock_available_display/static/description/index.html b/website_sale_stock_available_display/static/description/index.html new file mode 100644 index 0000000..1ee4193 --- /dev/null +++ b/website_sale_stock_available_display/static/description/index.html @@ -0,0 +1,443 @@ + + + + + + +Website Sale Stock Available Display + + + +
+

Website Sale Stock Available Display

+ + +

Beta License: AGPL-3 OCA/e-commerce Translate me on Weblate Try me on Runbot

+

This module extends the functionality of website sale stock module to allow to +display available stock in website products and allow to buy if not enough +stock. +Also re-use the field Custom Message for inform to customer of any message +when stock is less than 0.0 units.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to ‘Sale > Catalog > Product’.
  2. +
  3. Set Show inventory on website and allow sales if not enough stock in +inventory availability field.
  4. +
  5. You can set a custom message that appears when available stock is less than +0.0 units.
  6. +
  7. Go to Website Shop.
  8. +
  9. Click in any product that you know that no stock available.
  10. +
  11. You will see ‘0 units in stock’ but you will buy this product.
  12. +
+
+
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

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

+
+
+
+ + diff --git a/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display.js b/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display.js new file mode 100644 index 0000000..81c6112 --- /dev/null +++ b/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display.js @@ -0,0 +1,15 @@ +odoo.define('website_sale_stock_available_display.load', function (require) { + 'use strict'; + var ajax = require('web.ajax'); + var core = require('web.core'); + var ProductConfiguratorMixin = require( + 'website_sale_stock.ProductConfiguratorMixin'); + var QWeb = core.qweb; + var load_xml = ajax.loadXML( + '/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml', + QWeb + ); + load_xml.then(function() { + $('.oe_website_sale').find('input[name="add_qty"]').trigger('change'); + }); +}); diff --git a/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display_tour.js b/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display_tour.js new file mode 100644 index 0000000..f404002 --- /dev/null +++ b/website_sale_stock_available_display/static/src/js/website_sale_stock_available_display_tour.js @@ -0,0 +1,59 @@ +/* Copyright 2019 Sergio Teruel + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +odoo.define("website_sale_stock_available_display.tour", function (require) { + "use strict"; + + var tour = require("web_tour.tour"); + var base = require("web_editor.base"); + + var steps = [ + { + trigger: "a:contains('Computer Motherboard')", + }, + { + trigger: "a#add_to_cart", + extra_trigger: ".availability_messages:has(span:contains('0 Unit(s) in stock')):has(div:contains('Available in 10 days'))", + }, + { + trigger: "span:contains('Process Checkout')", + extra_trigger: ".availability_messages:has(span:contains('0 Unit(s) in stock'))", + }, + { + trigger: ".btn-primary:contains('Confirm Order')", + }, + { + trigger: "a[href='/shop']", + extra_trigger: ".availability_messages:has(span:contains('0 Unit(s) in stock'))", + }, + { + trigger: "a:contains('Special Mouse')", + }, + { + trigger: "a#add_to_cart", + extra_trigger: ".availability_messages:has(span:contains('10 Unit(s) in stock'))", + }, + { + trigger: "span:contains('Process Checkout')", + extra_trigger: ".availability_messages:has(span:contains('10.0 Unit(s) in stock'))", + }, + { + trigger: ".btn-primary:contains('Confirm Order')", + }, + { + trigger: "a[href='/shop']", + extra_trigger: ".availability_messages:has(span:contains('10.0 Unit(s) in stock'))", + }, + ]; + tour.register("website_sale_stock_available_display", + { + url: "/shop", + test: true, + wait_for: base.ready(), + }, + steps + ); + return { + steps: steps, + }; +}); diff --git a/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml b/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml new file mode 100644 index 0000000..9094ac6 --- /dev/null +++ b/website_sale_stock_available_display/static/src/xml/website_sale_stock_product_availability.xml @@ -0,0 +1,20 @@ + + + + + + +
+ + + in stock +
+
+ + +
+
+
+
+ +
diff --git a/website_sale_stock_available_display/tests/__init__.py b/website_sale_stock_available_display/tests/__init__.py new file mode 100644 index 0000000..c64352d --- /dev/null +++ b/website_sale_stock_available_display/tests/__init__.py @@ -0,0 +1 @@ +from . import test_website_sale_stock_available_display diff --git a/website_sale_stock_available_display/tests/test_website_sale_stock_available_display.py b/website_sale_stock_available_display/tests/test_website_sale_stock_available_display.py new file mode 100644 index 0000000..8cf0564 --- /dev/null +++ b/website_sale_stock_available_display/tests/test_website_sale_stock_available_display.py @@ -0,0 +1,57 @@ +# Copyright 2019 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.tests.common import HttpCase + + +class websiteSaleStockAvailableDisplay(HttpCase): + + def setUp(self): + super().setUp() + # For testing with website_sale_vat_required module, I avoid + # address step to fill partner vat + self.env.ref('base.user_admin').partner_id.write({ + 'vat': 'BE0477472701', + 'phone': '9999999999', + }) + self.ProductTemplate = self.env['product.template'] + # The website_sequence is set quite high to display this products in + # first page. + # Set list price to 0.0 to avoid payment step because this step has an + # asynchronous call + common_vals = { + 'type': 'product', + 'website_published': True, + 'inventory_availability': 'always_no_lock', + 'website_sequence': 5000, + 'list_price': 0.0, + } + vals = common_vals.copy() + vals.update({ + 'name': 'Computer Motherboard', + 'custom_message': 'Available in 10 days', + }) + self.product_template_wo_qty = self.ProductTemplate.create(vals) + vals = common_vals.copy() + vals.update({ + 'name': 'Special Mouse', + }) + self.product_product_w_qty = self.ProductTemplate.create(vals) + self.env['stock.quant'].create({ + 'product_id': self.product_product_w_qty.product_variant_ids.id, + 'product_uom_id': self.product_product_w_qty.uom_id.id, + 'location_id': self.env.ref('stock.stock_location_stock').id, + 'quantity': 10.0, + }) + + def test_ui_website(self): + """Test frontend tour.""" + tour = ( + "odoo.__DEBUG__.services['web_tour.tour']", + "website_sale_stock_available_display", + ) + self.browser_js( + url_path="/shop", + code="%s.run('%s')" % tour, + ready="%s.tours['%s'].ready" % tour, + login="admin" + ) diff --git a/website_sale_stock_available_display/views/assets.xml b/website_sale_stock_available_display/views/assets.xml new file mode 100644 index 0000000..8d6f626 --- /dev/null +++ b/website_sale_stock_available_display/views/assets.xml @@ -0,0 +1,11 @@ + + +