[ADD] stock_ux: auto-activate multi-warehouse group for branch warehouses - #970
Open
mav-adhoc wants to merge 1 commit into
Open
[ADD] stock_ux: auto-activate multi-warehouse group for branch warehouses#970mav-adhoc wants to merge 1 commit into
mav-adhoc wants to merge 1 commit into
Conversation
Collaborator
There was a problem hiding this comment.
Pull request overview
Este PR mejora la UX de inventario en stock_ux activando automáticamente el grupo estándar “Gestionar varios almacenes” cuando existen sucursales (compañías hijas) con almacenes, agregando el conteo por árbol de compañías (company_id.root_id) en lugar de por compañía individual.
Changes:
- Override de
stock.warehouse._check_multiwarehouse_group()para calcular el máximo de almacenes activos por root company mediante un helper_multiwarehouse_max_count(). - Nuevos tests para cubrir el escenario “madre + sucursal, 1 almacén por compañía” y la activación del grupo.
- Actualización de README y bump de versión del módulo.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| stock_ux/models/stock_warehouse.py | Override de la lógica de activación del grupo multi-almacén agregando el conteo por root_id. |
| stock_ux/models/init.py | Export del nuevo archivo de modelo. |
| stock_ux/tests/test_multiwarehouse_group.py | Tests nuevos para el conteo agregado por árbol y la activación del grupo. |
| stock_ux/tests/init.py | Import del módulo de tests para su carga. |
| stock_ux/README.rst | Documenta la nueva funcionalidad de auto-activación. |
| stock_ux/manifest.py | Bump de versión del módulo. |
Comment on lines
+25
to
+27
| Warehouse = self.env["stock.warehouse"] | ||
| parent = self._create_company("UX Madre") | ||
| branch = self._create_company("UX Sucursal", parent=parent) |
Comment on lines
+47
to
+49
| group_user = self.env.ref("base.group_user") | ||
| group_multi_wh = self.env.ref("stock.group_stock_multi_warehouses") | ||
|
|
mav-adhoc
force-pushed
the
19.0-t-69369-mav
branch
2 times, most recently
from
July 3, 2026 16:46
36046e0 to
f3f68af
Compare
mav-adhoc
force-pushed
the
19.0-t-69369-mav
branch
from
August 6, 2026 13:08
f3f68af to
6f6adde
Compare
mav-adhoc
force-pushed
the
19.0-t-69369-mav
branch
from
August 18, 2026 14:58
6f6adde to
f86f7cd
Compare
…uses Native stock._check_multiwarehouse_group counts active warehouses grouped by company_id, so it only activates "Manage Multiple Warehouses" when a single company has more than one warehouse. When a company uses branches (child companies), each branch is a separate company_id with its own warehouse, so the count stays at 1 per company and the group is never activated. Override the method in stock_ux to count the warehouses by company tree (company_id.root_id), so a parent company and its branches are counted together. The count also skips the warehouses of archived companies, and the check now runs when a company is archived or restored: archiving a branch does not archive its warehouse, so the count never went down and the permission stayed on with no way to turn it off from the interface. Includes tests covering the aggregation by company tree, the group activation, the deactivation when the branch (or its warehouse) is archived, and the unchanged behaviour for companies without branches.
mav-adhoc
force-pushed
the
19.0-t-69369-mav
branch
from
August 18, 2026 16:44
f86f7cd to
2046d08
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Make the standard Manage Multiple Warehouses group
(
stock.group_stock_multi_warehouses) follow the warehouses of the wholecompany tree: activate it when a company has branches (child
companies) that own warehouses — even with a single warehouse each — and turn
it off again when those warehouses, or their branches, are archived.
Why
Native
stock.warehouse._check_multiwarehouse_group()counts activewarehouses grouped by
company_id, and only activates the group when asingle company has more than one warehouse. A branch is a child
res.companywith its owncompany_id, so a setup with one warehouse perbranch leaves the per-company count at 1 and the multi-warehouse UI is never
enabled. The behaviour is the same on 18.0; this generalizes the counting.
The other half is the way back. Archiving a company does not archive its
warehouses, and the native check only runs on warehouse
create/ archive /unlink, so archiving a branch left the count untouched and the permissionon — with no way to turn it off from the interface: Settings refuses to
untick Storage Locations while multi-warehouse is implied
(
res.config.settings.set_values), and multi-warehouse itself is not auser-facing checkbox.
How
Override the method in
stock_ux:_multiwarehouse_count_by_root_company()counts active warehouses ofactive companies, aggregated by
company_id.root_id(the top of thecompany tree), so a parent company and its branches count together.
_check_multiwarehouse_group()activates / deactivates on that count. Fora company without branches
root_idis the company itself, so nothingchanges for non-branch setups.
res.company.write()re-runs the check when a company is archived orrestored — the events that change which warehouses are in play and that the
native method never sees. (The hierarchy itself cannot change afterwards:
res.company.writerefusesparent_id.)Test plan
stock_ux/tests/test_multiwarehouse_group.py:test_warehouses_are_counted_by_company_tree: parent + branch, onewarehouse each, count 1 per
company_idnatively but 2 under the root.test_branch_warehouse_activates_multi_wh_group: starting with the groupnot implied, creating a branch with a warehouse activates it.
test_archived_branch_deactivates_group: archiving the branch (itswarehouse stays active) drops the count and removes the group.
test_unarchived_branch_activates_group_again: and restoring it puts thegroup back.
test_archived_branch_warehouse_deactivates_group: same going through thewarehouse instead of the company.
test_single_warehouse_per_company_deactivates_group: no regression forsetups without branches.
0 failed, 0 error(s) of 8 testslocally with-u stock_ux --test-enable --test-tags /stock_ux. Each piece was checked in isolation: dropping theres.companyhook, or the active-company filter in the count, makestest_archived_branch_deactivates_groupandtest_unarchived_branch_activates_group_againfail.Task: https://www.adhoc.inc/odoo/my-tasks/69369