[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
from
July 3, 2026 16:39
81d1739 to
36046e0
Compare
…uses Native stock._check_multiwarehouse_group counts active warehouses grouped by company_id, so it only activates the "Manage Several Warehouses" group 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 aggregate the warehouse count by company_id.root_id (the top of the company tree), so a parent company and its branches are counted together. For a company without branches root_id is the company itself, so behaviour is identical to the native one. Includes tests covering the tree aggregation and the effective group activation.
mav-adhoc
force-pushed
the
19.0-t-69369-mav
branch
from
July 3, 2026 16:46
36046e0 to
f3f68af
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
Auto-activate the standard Manage Several Warehouses group
(
stock.group_stock_multi_warehouses) when a company has branches(child companies) that own warehouses — even if each branch holds a single
warehouse.
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.
How
Override the method in
stock_uxand aggregate the active-warehouse count bycompany_id.root_id(the top of the company tree) via a small_multiwarehouse_max_count()helper, so a parent company and its branchesare counted together. For a company without branches
root_idis thecompany itself, so behaviour is identical to the native method (no regression
for non-branch setups). The toggle logic (activate / deactivate) is kept
in sync with the native method.
Test plan
New
stock_ux/tests/test_multiwarehouse_group.py:test_branch_warehouses_share_root_and_aggregate: a parent + branch, eachwith one warehouse, count 1 per
company_idnatively but aggregate to >=2by root company tree.
test_branch_warehouse_activates_multi_wh_group: creating a branch with awarehouse activates the multi-warehouse group.
Both green locally (
--test-tags /stock_ux).Task: https://www.adhoc.inc/odoo/my-tasks/69369