Skip to content

[ADD] website_sale_stock_hide_unavailable: hide or push down out-of-stock products - #493

Closed
fw-bot-adhoc wants to merge 20 commits into
ingadhoc:20.0from
adhoc-dev:20.0-19.0-t-72806-jr-8773-fw
Closed

fw-bot-adhoc wants to merge 20 commits into
ingadhoc:20.0from
adhoc-dev:20.0-19.0-t-72806-jr-8773-fw

Conversation

@fw-bot-adhoc

Copy link
Copy Markdown

What

New module that lets each website decide what the shop does with storable products that are out of stock and cannot be sold out of stock:

  • Show (default): identical to standard Odoo.
  • Show at the end of the list: out-of-stock products appear last, in any sort order.
  • Hide: out-of-stock products disappear from the listing, site search, sitemap, accessory/alternative blocks and per-category product counts.

In every mode the product page keeps responding 200, so indexed URLs and SEO are preserved during a temporary stock break.

Why

On shops with many out-of-stock products the /shop listing fills with unbuyable products and reads as empty or stale. Odoo does not solve this natively because computing availability on every listing is expensive.

How

  • Precomputed table product.template.stock.availability, keyed by (product_tmpl_id, warehouse_id, company_id). A row means unavailable; absence means visible, so missing data fails open (a sellable product is never hidden by a stale computation).
  • One override of website.sale_product_domain() adds a not any sub-query, covering all five consumers (listing, search, sitemap, accessories/alternatives, category count) at once. The "at the end" order is a stable Python re-sort in the shop controller.
  • A stock.quant hook enqueues the touched candidates with a single SQL statement (no row locks on product.template). Two crons reconcile the table: a 5-minute drain and a nightly full sweep, both reusing the standard batched free_qty compute (mrp kits, expiry, etc. respected — no custom read_group on stock.quant).

Warehouse scope is the website's warehouse, or the whole company when empty. The union-of-published-warehouses case is out of scope and left to a future bridge via two overridable seams (_hide_unavailable_scope_leaf, _hide_unavailable_free_qty).

Scope / limitations

  • Products with several variants are never hidden (matches _is_sold_out, which only checks the first variant).
  • With website_sale_collect (Click & Collect) availability is per visitor and cannot be represented on the product, so the filter does not apply.

Tests

tests/test_hide_unavailable.py covers show/hide/last, allow_out_of_stock_order, variant exclusion and reappearance, company-wide vs specific-warehouse scope, two websites with distinct warehouses, the enqueue hook and the drain-cron round trip.

Forward-Port-Of: #486

@roboadhoc

Copy link
Copy Markdown
Contributor

Pull request status dashboard

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@JrAdhoc @augusto-weiss this PR targets 20.0 and is the last of the forward-port chain.

To merge the full chain, use

@roboadhoc r+

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@JrAdhoc @augusto-weiss ci/runbot-modified-modules failed on this forward-port PR

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@JrAdhoc @augusto-weiss this forward port of #486 is awaiting action (not merged or closed).

2 similar comments
@fw-bot-adhoc

Copy link
Copy Markdown
Author

@JrAdhoc @augusto-weiss this forward port of #486 is awaiting action (not merged or closed).

@fw-bot-adhoc

Copy link
Copy Markdown
Author

@JrAdhoc @augusto-weiss this forward port of #486 is awaiting action (not merged or closed).

@JrAdhoc
JrAdhoc force-pushed the 20.0-19.0-t-72806-jr-8773-fw branch 2 times, most recently from 09cca7c to 0c7bc98 Compare November 3, 2026 14:02
JrAdhoc and others added 20 commits November 3, 2026 14:39
…tock products

Let each website choose what the shop does with storable, out-of-stock products
that cannot be sold out of stock: show them (default), push them to the end of
the listing, or hide them from listing, site search, sitemap,
accessories/alternatives and per-category counts. The product page keeps
responding 200, so indexed URLs and SEO are preserved.

Availability is precomputed in a small per-scope table (a row means the product
is unavailable; absence means visible, so missing data fails open). The
storefront adds a single 'not any' sub-query to the domain it already builds in
website.sale_product_domain, covering all five consumers at once; the "at the
end" order is a stable re-sort in the shop controller. A stock.quant hook
enqueues the touched candidates with one SQL statement, and two crons (5-minute
drain + nightly full sweep) reconcile the table reusing the standard batched
free_qty compute. No core patch.

The warehouse scope is (warehouse or company-wide when empty); union of
published warehouses is out of scope and left to a bridge via two overridable
seams.

X-original-commit: 7c431f7
…20.0

Three methods the module called are gone in 20.0, and all three raise
AttributeError at runtime instead of failing at install time.

website.get_current_website() no longer exists on the model. The core calls
sale_product_domain() on an empty recordset from the category listing and the
shop search, so the "hide" mode broke there. Odoo 20 solves it in the very
method we override with `self or self.env.website`
(website_sale/models/website.py:700), so we use the same pattern.

ir.config_parameter.get_param() and set_param() are replaced by typed
accessors. The sweep cursor is an integer, so get_int()/set_int() are the
exact equivalent: they already return the default when the key is missing or
the stored value is invalid, which is what the int() wrapper did.
… variants

The module skipped any product with more than one variant, because it assumed
_is_sold_out() only looked at the first one. That stopped being true in 19.0:
website_sale_stock/models/product_template.py:33 already reports a template as
sold out only when every variant is (commit ba97cc24c). In 20.0 the method
moved to website_sale/models/product_template.py:1944 with the same rule.

So the module was out of step with both the out-of-stock ribbon and the new
"In stock" shop filter: a product whose variants were all out of stock showed
the ribbon but stayed in the listing.

Availability is now read over product_variant_ids, in the same batch as
before, and the product is only hidden when no variant has stock left.
…ith SQL

_get_unavailable_tmpl_ids runs on every shop request in "last" mode, and it
was reading the rows of the scope as records only to intersect their ids.
Building that recordset is wasted work on a catalogue with many sold-out
products.

It now reads the ids in a single query. The scope filter uses IS NOT DISTINCT
FROM because warehouse_id is NULL on the company-wide rows, and the model is
flushed first so pending ORM writes are visible to the raw query.
…sels too

The dynamic snippets never go through website.sale_product_domain(), so the
single override that covers the listing, the search, the sitemap, the
accessory blocks and the category counts never reached the homepage
carousels: a product hidden everywhere else still showed up there.

There are two paths to cover, and they meet in _prepare_values: a filter
backed by an ir.filters searches with its own domain (the "All" and "Newest"
carousels), while one backed by a server action ends up in _get_products(),
which builds another one (the "Recently sold", "Recently viewed" and
accessory carousels). Adding the leaf once in _prepare_values covers both.

search_domain stays a list because website_sale reads and pops its
"hide_variants" marker out of it before the base turns it into a Domain.
…ublishing

Odoo 20 adds "Unpublish out-of-stock products", which solves a similar
problem in a way this module deliberately avoids: it is one switch for the
whole database instead of a setting per website, it overwrites manual
publishing, and it unpublishes the product, so its page stops answering 200
and the indexed URL is lost during a temporary stock break.

Running both is not an error, but it defeats the purpose of this module. The
setting is now hidden from the Settings page, and a post_init_hook turns the
group off on install: hiding the field alone would leave a database that
already had it on with no way to turn it off from the interface.

Hiding the field does not stop anyone from enabling the group over RPC.
Closing that too would mean overriding product.template._compute_is_published
without calling super(), which can break website_sale's own test_auto_unpublish,
so it is left out on purpose.
A kit (a product with a phantom bill of materials) has no stock of its own:
free_qty already derives it from the components. The queue that keeps the
precomputed table fresh, though, walks quant -> product -> template, so moving
a component's stock never reached the kit and it stayed listed in the shop
until the nightly sweep.

The enqueue grows a seam, _hide_unavailable_extra_templates, and this bridge
fills it with the kits whose components the quants hold, following nested
bills of materials as deep as they go. It is auto_install, so the base module
keeps working on a shop without manufacturing and does not change which
databases it can be installed on.
What the migration changed: products with several variants are now hidden when
every variant is out of stock, the carousels are covered, kits need the new
bridge, and Odoo 20's own unpublishing is hidden and turned off on install,
with the RPC caveat written down. The "back in stock" funnel is named by the
20.0 model, product.stock.notification.

Adds a "Technical details" section, like website_sale_cart_offcanvas already
has: the two tables and the polarity rule, why the One2many bypasses search
access, where each extension point sits and what the bridge seam is for.

Also records why a serialization error between the two crons is left to
Odoo's retry instead of being caught.
…te for 20.0

Re-export of the source terms and the es_419 translation of both modules. The
previous es.po carried no translation of its own, so nothing was overwritten.

The module description, which 20.0 exports from the README, is left untranslated
on purpose: it carries reST directives, URLs and code blocks that are easy to
break. "ID" is left untranslated as a technical term.
…rousels

The previous commit said _prepare_values covered both kinds of dynamic filter.
It covered one. It read the model from filter_id, which is empty on a filter
backed by a server action, so the condition never matched and the leaf was
never added: "Recently sold", "Recently viewed" and "Sold with" kept showing
products the shop hides.

The model now comes from model_name, the computed field that resolves
filter_id and action_server_id alike, which is what website_sale reads in the
same method (website_sale/models/website_snippet_filter.py:21).

The test that was there used an ir.filters, exactly the half that worked, so
it stayed green with the hole open. A second test covers the server-action
path and fails without this change.
… archived

Now that availability is read over every variant, archiving the only variant
with stock leaves the template unavailable, and unarchiving it brings it back.
Neither enqueued anything: the triggers only watched stored template columns,
so the shop kept the old answer until the nightly sweep.

Archiving every variant archives and unpublishes the template, so that case
never reached the queue to begin with and still does not need to.
…anging

A kit's availability comes from its components, so it changes when the bill
changes, not only when stock moves. Adding a component with no stock left the
kit listed until the nightly sweep — the very symptom the module exists to
fix, reached through another door.

Covers the bill being created, written, dropped, and its lines being added,
changed or removed. A write enqueues before and after, so a bill that stops
being a kit is reconciled too.
Odoo's native unpublishing is no longer turned off on install. Installing the
module left every website on its default "show" and still stripped the group,
so a database that relied on the native behaviour lost it without getting
anything in return, and could not turn it back on because the setting was
hidden unconditionally. It is turned off when a website moves to "hide" or
"last", and the setting is only hidden on a website that is in one of those
modes. The post_init_hook is gone.

The variant hook enqueued every touched template with no filter, so a mass
archive flooded the queue; it now enqueues candidates, plus the ones that still
have rows to clear.

In the bridge: the hot enqueue path ran an mrp.bom.line search on every quant
batch even with no kit in the database, and mrp.bom.write enqueued twice on any
write. Both are gated now.

Tests: the native-unpublishing one asserts through _is_feature_enabled, which is
what the core reads, instead of a group link that _apply_group may not create;
and a new one proves a kit is actually hidden when its components run out and
visible again when they come back — until now nothing covered that claim.

Also: "Quant" is translated as the core does ("Cantidad", not "Cant"), the
bridge catalogue gets its missing Language header, and the rationale docstrings
this diff had added are cut back to the house style.
…r without Inventory

Asked for by the PO on task 78510. Three things that only make sense together.

It ships with the shop. depends drops to website_sale and the module is
auto_install, so every database that installs eCommerce from now on gets it.
An existing one is a decision of the upgrade scripts: auto_install only fires
while a dependency is being installed, and the upgrade's auto discovery only
triggers it for modules the database has never seen.

That is also why Odoo's native "Unpublish out-of-stock products" is no longer
offered at all, instead of only where this module was configured: the two solve
the same problem and only one of them is ever on screen. Taking it over means
two things, on install and on upgrade. The group goes. And what it had already
unpublished is republished, in batches and keeping its publish date, because
with the group gone its compute stops running and those products would stay
down for good.

Nothing keeps checking afterwards. Odoo's settings page reads the group before
saving and writes back what it read, so a module undoing it mid-save only gets
undone in turn -- and taking it off there breaks website_sale's own
TestAutoUnpublishOutOfStock, which is the native feature still working for
whoever does turn it back on. Enabling the group over RPC stays possible, and
the README says so.

It runs without Inventory. Odoo 20 keeps a company-wide qty_available in
product, moved by invoices and sales orders, and website_sale reads it through
website._get_product_available_qty(). Asking that seam instead of reading
free_qty with a warehouse in the context is what makes the same code answer in
both worlds: without Inventory it resolves company-wide, and with it
website_sale_stock injects the website's warehouse.

So the scope of the precomputed table is the website, not the warehouse:
the website is what knows how its availability is measured. That also drops
the partial index the NULL warehouse needed, and the upgrade script empties the
table so the new key applies: the rows are a precomputed answer the crons
derive again, and a missing row means visible.

What enqueues a product follows the same split. Here: qty_available changing on
the variant, which is also how a posted invoice moves it, and a sales order
being confirmed, cancelled or having its lines changed, which is what moves the
outgoing quantity free_qty subtracts. The stock.quant hook moves to the
Inventory bridge.

Shipping with the shop also means most databases never turn it on, so nothing
is queued and the nightly sweep walks nothing while every website is on Show.
That answer is cached: website already invalidates it on create, write and
unlink.

Also: the sweep now reads the orphan rows with a domain instead of loading the
whole table to filter it in Python.
With Inventory installed, stock moves instead of qty_available, and none of
the core module's triggers see it. This bridge carries the stock.quant hook
that used to live there, plus a reconcile when the warehouse of a website
changes, which changes every answer for that site.

The availability figure needs no bridge: website_sale_stock already overrides
website._get_product_available_qty() to measure against the warehouse, and
that is what the core module asks.

The mrp bridge now hangs off this one, which is where the enqueue seam lives.
…shape

The module no longer gets installed on purpose, no longer needs Inventory and
no longer scopes by warehouse, so the README said three things the code does
not do. It now explains where availability comes from in each world, that the
scope is the website, what enqueues a product on each side, and that the
native setting is never offered.

Installation says what actually happens: nothing on a database that installs
eCommerce from now on, and an existing one is a decision of the upgrade
scripts, because auto_install only fires while a dependency is being installed
and the upgrade's auto discovery only triggers it for modules the database has
never seen.

Two claims that were wrong go with it: the filter does apply with Click &
Collect, measuring the way that module measures, and Hide also drops the
product from the Google Merchant Center feed.
…fter the redesign

The warehouse and company columns took their terms with them, and so did the
account.move override; what the new unique constraint and sale.order.line bring
is translated. The two bridges carried their pre-redesign description, which
20.0 exports from the README, so they are re-exported too, and the mrp one
gains the two terms it took from its new parent. The description itself stays
untranslated on purpose, as does "ID".
@JrAdhoc
JrAdhoc force-pushed the 20.0-19.0-t-72806-jr-8773-fw branch from 0c7bc98 to 7350a68 Compare November 3, 2026 17:40
@augusto-weiss

Copy link
Copy Markdown
Contributor

@roboadhoc r+ nobump rebase-ff

@roboadhoc

Copy link
Copy Markdown
Contributor

Merge method set to rebase and fast-forward.

roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…tock products

Let each website choose what the shop does with storable, out-of-stock products
that cannot be sold out of stock: show them (default), push them to the end of
the listing, or hide them from listing, site search, sitemap,
accessories/alternatives and per-category counts. The product page keeps
responding 200, so indexed URLs and SEO are preserved.

Availability is precomputed in a small per-scope table (a row means the product
is unavailable; absence means visible, so missing data fails open). The
storefront adds a single 'not any' sub-query to the domain it already builds in
website.sale_product_domain, covering all five consumers at once; the "at the
end" order is a stable re-sort in the shop controller. A stock.quant hook
enqueues the touched candidates with one SQL statement, and two crons (5-minute
drain + nightly full sweep) reconcile the table reusing the standard batched
free_qty compute. No core patch.

The warehouse scope is (warehouse or company-wide when empty); union of
published warehouses is out of scope and left to a bridge via two overridable
seams.

X-original-commit: 7c431f7
Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
(cherry picked from commit 278edce)

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…20.0

Three methods the module called are gone in 20.0, and all three raise
AttributeError at runtime instead of failing at install time.

website.get_current_website() no longer exists on the model. The core calls
sale_product_domain() on an empty recordset from the category listing and the
shop search, so the "hide" mode broke there. Odoo 20 solves it in the very
method we override with `self or self.env.website`
(website_sale/models/website.py:700), so we use the same pattern.

ir.config_parameter.get_param() and set_param() are replaced by typed
accessors. The sweep cursor is an integer, so get_int()/set_int() are the
exact equivalent: they already return the default when the key is missing or
the stored value is invalid, which is what the int() wrapper did.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
… variants

The module skipped any product with more than one variant, because it assumed
_is_sold_out() only looked at the first one. That stopped being true in 19.0:
website_sale_stock/models/product_template.py:33 already reports a template as
sold out only when every variant is (commit ba97cc24c). In 20.0 the method
moved to website_sale/models/product_template.py:1944 with the same rule.

So the module was out of step with both the out-of-stock ribbon and the new
"In stock" shop filter: a product whose variants were all out of stock showed
the ribbon but stayed in the listing.

Availability is now read over product_variant_ids, in the same batch as
before, and the product is only hidden when no variant has stock left.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…ith SQL

_get_unavailable_tmpl_ids runs on every shop request in "last" mode, and it
was reading the rows of the scope as records only to intersect their ids.
Building that recordset is wasted work on a catalogue with many sold-out
products.

It now reads the ids in a single query. The scope filter uses IS NOT DISTINCT
FROM because warehouse_id is NULL on the company-wide rows, and the model is
flushed first so pending ORM writes are visible to the raw query.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…sels too

The dynamic snippets never go through website.sale_product_domain(), so the
single override that covers the listing, the search, the sitemap, the
accessory blocks and the category counts never reached the homepage
carousels: a product hidden everywhere else still showed up there.

There are two paths to cover, and they meet in _prepare_values: a filter
backed by an ir.filters searches with its own domain (the "All" and "Newest"
carousels), while one backed by a server action ends up in _get_products(),
which builds another one (the "Recently sold", "Recently viewed" and
accessory carousels). Adding the leaf once in _prepare_values covers both.

search_domain stays a list because website_sale reads and pops its
"hide_variants" marker out of it before the base turns it into a Domain.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…ublishing

Odoo 20 adds "Unpublish out-of-stock products", which solves a similar
problem in a way this module deliberately avoids: it is one switch for the
whole database instead of a setting per website, it overwrites manual
publishing, and it unpublishes the product, so its page stops answering 200
and the indexed URL is lost during a temporary stock break.

Running both is not an error, but it defeats the purpose of this module. The
setting is now hidden from the Settings page, and a post_init_hook turns the
group off on install: hiding the field alone would leave a database that
already had it on with no way to turn it off from the interface.

Hiding the field does not stop anyone from enabling the group over RPC.
Closing that too would mean overriding product.template._compute_is_published
without calling super(), which can break website_sale's own test_auto_unpublish,
so it is left out on purpose.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
A kit (a product with a phantom bill of materials) has no stock of its own:
free_qty already derives it from the components. The queue that keeps the
precomputed table fresh, though, walks quant -> product -> template, so moving
a component's stock never reached the kit and it stayed listed in the shop
until the nightly sweep.

The enqueue grows a seam, _hide_unavailable_extra_templates, and this bridge
fills it with the kits whose components the quants hold, following nested
bills of materials as deep as they go. It is auto_install, so the base module
keeps working on a shop without manufacturing and does not change which
databases it can be installed on.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
What the migration changed: products with several variants are now hidden when
every variant is out of stock, the carousels are covered, kits need the new
bridge, and Odoo 20's own unpublishing is hidden and turned off on install,
with the RPC caveat written down. The "back in stock" funnel is named by the
20.0 model, product.stock.notification.

Adds a "Technical details" section, like website_sale_cart_offcanvas already
has: the two tables and the polarity rule, why the One2many bypasses search
access, where each extension point sits and what the bridge seam is for.

Also records why a serialization error between the two crons is left to
Odoo's retry instead of being caught.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…te for 20.0

Re-export of the source terms and the es_419 translation of both modules. The
previous es.po carried no translation of its own, so nothing was overwritten.

The module description, which 20.0 exports from the README, is left untranslated
on purpose: it carries reST directives, URLs and code blocks that are easy to
break. "ID" is left untranslated as a technical term.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…rousels

The previous commit said _prepare_values covered both kinds of dynamic filter.
It covered one. It read the model from filter_id, which is empty on a filter
backed by a server action, so the condition never matched and the leaf was
never added: "Recently sold", "Recently viewed" and "Sold with" kept showing
products the shop hides.

The model now comes from model_name, the computed field that resolves
filter_id and action_server_id alike, which is what website_sale reads in the
same method (website_sale/models/website_snippet_filter.py:21).

The test that was there used an ir.filters, exactly the half that worked, so
it stayed green with the hole open. A second test covers the server-action
path and fails without this change.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
… archived

Now that availability is read over every variant, archiving the only variant
with stock leaves the template unavailable, and unarchiving it brings it back.
Neither enqueued anything: the triggers only watched stored template columns,
so the shop kept the old answer until the nightly sweep.

Archiving every variant archives and unpublishes the template, so that case
never reached the queue to begin with and still does not need to.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…anging

A kit's availability comes from its components, so it changes when the bill
changes, not only when stock moves. Adding a component with no stock left the
kit listed until the nightly sweep — the very symptom the module exists to
fix, reached through another door.

Covers the bill being created, written, dropped, and its lines being added,
changed or removed. A write enqueues before and after, so a bill that stops
being a kit is reconciled too.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
Odoo's native unpublishing is no longer turned off on install. Installing the
module left every website on its default "show" and still stripped the group,
so a database that relied on the native behaviour lost it without getting
anything in return, and could not turn it back on because the setting was
hidden unconditionally. It is turned off when a website moves to "hide" or
"last", and the setting is only hidden on a website that is in one of those
modes. The post_init_hook is gone.

The variant hook enqueued every touched template with no filter, so a mass
archive flooded the queue; it now enqueues candidates, plus the ones that still
have rows to clear.

In the bridge: the hot enqueue path ran an mrp.bom.line search on every quant
batch even with no kit in the database, and mrp.bom.write enqueued twice on any
write. Both are gated now.

Tests: the native-unpublishing one asserts through _is_feature_enabled, which is
what the core reads, instead of a group link that _apply_group may not create;
and a new one proves a kit is actually hidden when its components run out and
visible again when they come back — until now nothing covered that claim.

Also: "Quant" is translated as the core does ("Cantidad", not "Cant"), the
bridge catalogue gets its missing Language header, and the rationale docstrings
this diff had added are cut back to the house style.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…r without Inventory

Asked for by the PO on task 78510. Three things that only make sense together.

It ships with the shop. depends drops to website_sale and the module is
auto_install, so every database that installs eCommerce from now on gets it.
An existing one is a decision of the upgrade scripts: auto_install only fires
while a dependency is being installed, and the upgrade's auto discovery only
triggers it for modules the database has never seen.

That is also why Odoo's native "Unpublish out-of-stock products" is no longer
offered at all, instead of only where this module was configured: the two solve
the same problem and only one of them is ever on screen. Taking it over means
two things, on install and on upgrade. The group goes. And what it had already
unpublished is republished, in batches and keeping its publish date, because
with the group gone its compute stops running and those products would stay
down for good.

Nothing keeps checking afterwards. Odoo's settings page reads the group before
saving and writes back what it read, so a module undoing it mid-save only gets
undone in turn -- and taking it off there breaks website_sale's own
TestAutoUnpublishOutOfStock, which is the native feature still working for
whoever does turn it back on. Enabling the group over RPC stays possible, and
the README says so.

It runs without Inventory. Odoo 20 keeps a company-wide qty_available in
product, moved by invoices and sales orders, and website_sale reads it through
website._get_product_available_qty(). Asking that seam instead of reading
free_qty with a warehouse in the context is what makes the same code answer in
both worlds: without Inventory it resolves company-wide, and with it
website_sale_stock injects the website's warehouse.

So the scope of the precomputed table is the website, not the warehouse:
the website is what knows how its availability is measured. That also drops
the partial index the NULL warehouse needed, and the upgrade script empties the
table so the new key applies: the rows are a precomputed answer the crons
derive again, and a missing row means visible.

What enqueues a product follows the same split. Here: qty_available changing on
the variant, which is also how a posted invoice moves it, and a sales order
being confirmed, cancelled or having its lines changed, which is what moves the
outgoing quantity free_qty subtracts. The stock.quant hook moves to the
Inventory bridge.

Shipping with the shop also means most databases never turn it on, so nothing
is queued and the nightly sweep walks nothing while every website is on Show.
That answer is cached: website already invalidates it on create, write and
unlink.

Also: the sweep now reads the orphan rows with a domain instead of loading the
whole table to filter it in Python.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
With Inventory installed, stock moves instead of qty_available, and none of
the core module's triggers see it. This bridge carries the stock.quant hook
that used to live there, plus a reconcile when the warehouse of a website
changes, which changes every answer for that site.

The availability figure needs no bridge: website_sale_stock already overrides
website._get_product_available_qty() to measure against the warehouse, and
that is what the core module asks.

The mrp bridge now hangs off this one, which is where the enqueue seam lives.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
roboadhoc pushed a commit that referenced this pull request Nov 4, 2026
…shape

The module no longer gets installed on purpose, no longer needs Inventory and
no longer scopes by warehouse, so the README said three things the code does
not do. It now explains where availability comes from in each world, that the
scope is the website, what enqueues a product on each side, and that the
native setting is never offered.

Installation says what actually happens: nothing on a database that installs
eCommerce from now on, and an existing one is a decision of the upgrade
scripts, because auto_install only fires while a dependency is being installed
and the upgrade's auto discovery only triggers it for modules the database has
never seen.

Two claims that were wrong go with it: the filter does apply with Click &
Collect, measuring the way that module measures, and Hide also drops the
product from the Google Merchant Center feed.

Part-of: #493
Signed-off-by: Augusto Weiss <[email protected]>
@roboadhoc roboadhoc added the 19.1 label Nov 4, 2026
@roboadhoc roboadhoc closed this in 1354062 Nov 4, 2026
@roboadhoc
roboadhoc deleted the 20.0-19.0-t-72806-jr-8773-fw branch November 4, 2026 19:10

This branch was previously deployed

1 inactive deployment
merge — 7350a688 Deployed Nov 4, 2026 by roboadhoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants