Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions website_sale_stock_location_filter/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

==================================
Website Sale Stock Location Filter
==================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9c6675b4355bfe166b7c021df03bc8dcd03cbd5efd3073862a6f824109020476
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.0/website_sale_stock_location_filter
: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-19-0/e-commerce-19-0-website_sale_stock_location_filter
: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/e-commerce&target_branch=19.0
:alt: Try me on Runboat

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

This module lets you choose, per stock location, whether its on-hand
quantity is counted towards the stock quantity displayed on the website
shop.

By default every internal location contributes to the displayed stock.
Internal locations that should not be shown to website visitors (for
example technician locations) can be flagged with **Exclude from Website
Stock** on the location form; their quantity is then left out of the
quantity shown on product pages.

The displayed quantity keeps using ``free_qty`` (on hand minus
reserved), exactly as standard Odoo does, restricted to the non-excluded
internal locations of the website's warehouse.

**Table of contents**

.. contents::
:local:

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_stock_location_filter%0Aversion:%2019.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
-------

* ForgeFlow

Contributors
------------

- Miquel Raïch <miquel.raich@forgeflow.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/19.0/website_sale_stock_location_filter>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions website_sale_stock_location_filter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import models
20 changes: 20 additions & 0 deletions website_sale_stock_location_filter/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Website Sale Stock Location Filter",
"summary": "Choose which stock locations count towards the stock "
"quantity displayed on the website shop.",
"version": "19.0.1.0.0",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-commerce",
"category": "Website/Website",
"depends": [
"website_sale_stock",
],
"data": [
"views/stock_location_views.xml",
],
"license": "AGPL-3",
"installable": True,
}
5 changes: 5 additions & 0 deletions website_sale_stock_location_filter/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import stock_location
from . import website
16 changes: 16 additions & 0 deletions website_sale_stock_location_filter/models/stock_location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class StockLocation(models.Model):
_inherit = "stock.location"

exclude_from_website_stock = fields.Boolean(
string="Exclude from Website Stock",
default=False,
help="If set, the on-hand quantity in this location is NOT counted "
"towards the stock quantity displayed on the website shop. "
"Only applies to internal locations.",
)
42 changes: 42 additions & 0 deletions website_sale_stock_location_filter/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2026 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import models


class Website(models.Model):
_inherit = "website"

def _get_website_stock_locations(self):
"""Return the internal locations whose stock is published on the shop.

Internal locations flagged with ``exclude_from_website_stock`` (e.g.
technician locations) are left out. When the website has a warehouse,
only that warehouse's locations are considered; otherwise all the
internal locations of the active companies are used (mirroring the
default behaviour of ``free_qty`` without a warehouse context).

Runs sudo: the shop exposes stock to public/portal visitors, who have
no read access to ``stock.location``. Standard ``free_qty`` never reads
locations directly (it goes through warehouses and sudoes the quants),
so resolving the location set ourselves needs the same elevation.
"""
self.ensure_one()
domain = [
("usage", "=", "internal"),
("exclude_from_website_stock", "=", False),
]
if self.warehouse_id:
domain.append(("id", "child_of", self.warehouse_id.view_location_id.id))
else:
domain.append(("company_id", "in", self.env.companies.ids))
return self.env["stock.location"].sudo().search(domain)

def _get_product_available_qty(self, product, **kwargs):
locations = self._get_website_stock_locations()
if not locations:
return 0.0
# ``strict=True`` makes ``free_qty`` count exactly these locations,
# without re-expanding to their children, so excluded sub-locations
# stay excluded. See stock.product._get_domain_locations_new.
return product.with_context(location=locations.ids, strict=True).free_qty
3 changes: 3 additions & 0 deletions website_sale_stock_location_filter/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions website_sale_stock_location_filter/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Miquel Raïch \<<miquel.raich@forgeflow.com>\>
13 changes: 13 additions & 0 deletions website_sale_stock_location_filter/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This module lets you choose, per stock location, whether its on-hand
quantity is counted towards the stock quantity displayed on the website
shop.

By default every internal location contributes to the displayed stock.
Internal locations that should not be shown to website visitors (for
example technician locations) can be flagged with **Exclude from Website
Stock** on the location form; their quantity is then left out of the
quantity shown on product pages.

The displayed quantity keeps using `free_qty` (on hand minus reserved),
exactly as standard Odoo does, restricted to the non-excluded internal
locations of the website's warehouse.
Loading
Loading