Skip to content

Commit

Permalink
Improve performance adding a techical field used in ir rules
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-dacosta committed Jun 19, 2019
1 parent a9a8441 commit 2be4f5a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 61 deletions.
2 changes: 1 addition & 1 deletion base_multi_company/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def set_security_rule(env, rule_ref):
'active': True,
'domain_force': (
"['|', ('company_ids', 'in', user.company_id.ids),"
" ('company_ids', '=', False)]"
" ('visible_for_all_companies', '=', True)]"
),
})

Expand Down
12 changes: 12 additions & 0 deletions base_multi_company/models/multi_company_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class MultiCompanyAbstract(models.AbstractModel):
auto_join=True,
default=lambda self: self._default_company_ids(),
)
visible_for_all_companies = fields.Boolean(
compute='_get_visible_for_all_companies',
store=True,
index=True,
default=True)

@api.depends('company_ids')
@api.multi
def _get_visible_for_all_companies(self):
for rec in self:
if not rec.company_ids:
rec.visible_for_all_companies = True

def _default_company_ids(self):
return self.browse(
Expand Down
1 change: 1 addition & 0 deletions base_multi_company/models/res_company_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ResCompanyAssignment(models.Model):

_name = 'res.company.assignment'
_auto = False
_description = "Res Company Assignment"

name = fields.Char()

Expand Down
6 changes: 6 additions & 0 deletions base_multi_company/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* Dave Lasley <dave@laslabs.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Cédric Pigeon <cedric.pigeon@acsone.eu>
* Rodrigo Ferreira <rodrigosferreira91@gmail.com>
* Florian da Costa <florian.dacosta@akretion.com>
4 changes: 4 additions & 0 deletions base_multi_company/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module provides an abstract model to be inherited by models that need
to implement multi-company functionality.

No direct functionality is provided by this module.
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
.. image:: https://img.shields.io/badge/licence-lgpl--3-blue.png
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3

==================
Multi Company Base
==================

This module provides an abstract model to be inherited by models that need
to implement multi-company functionality.

No direct functionality is provided by this module.

Implementation
==============
~~~~~~~~~~~~~~

Multi Company Abstract
----------------------
Expand Down Expand Up @@ -80,49 +67,3 @@ significant boilerplate when relevant.
A module implementing these hooks would need to first identify the proper rule
for the record (`product.product_comp_rule` in the above example).

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/133/12.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/multi-company/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smash it by providing detailed and welcomed
feedback.

Credits
=======

Images
------

* Odoo Community Association:
`Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

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

* Dave Lasley <dave@laslabs.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Laurent Mignon <laurent.mignon@acsone.eu>
* Cédric Pigeon <cedric.pigeon@acsone.eu>
* Rodrigo Ferreira <rodrigosferreira91@gmail.com>
* Florian da Costa <florian.dacosta@akretion.com>

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.

0 comments on commit 2be4f5a

Please sign in to comment.