Ready to use multi-company

Rational

In Issue 4080: Remove company record rules - Tryton issue tracker we made it possible to work on many companies in the same session. The problem is that most of the list views do not display the company field. This is mainly to not overload the view with a column with always the same value for the most common use case of mono-company.
So with standard views it is difficult to work on multi-company setup without customize many views.

Proposal

I propose to add the company column on all the list view. But to override all the ModelView with a Mixin that will set optional="1" to company field (any Many2One pointing to company.company) of all tree views if the number of company in the database is equal to 1.
But also to move out the company field from “Other Info” tab to the header of the forms as it needs to be visually checked by multi-company users.

Implementation

1 Like

Your proposal makes completly sense for me but I’m wondering if we should have a similar behaviour for Warehouse adding it to tree view and having the same Mixin.

Indeed that’s also a nice to have. The only problem is that we do not have a cached method to count the number of warehouses.

Do we have a chached method to count the number of companies? :scream:

Yes we have a cached method on all ModelStorage that count the number of record.

So to support warehouses we will have to implement a similar cached counting.

Maybe we can just add a domain argument to the current count function, so we can count the warehouses (but also any other domain clause).

Instead of using tree_invisible I think we should use the optional from Per user list view definition.

1 Like