Skip to content

Commit

Permalink
[FIX] change the cache of a method that needs to be company dependant
Browse files Browse the repository at this point in the history
Also updated the translation files
  • Loading branch information
vincent-hatakeyama committed Jun 14, 2022
1 parent 8936261 commit 461faac
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 13 deletions.
6 changes: 5 additions & 1 deletion ir_actions_report_multi_company/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Ir Actions Report Multi Company
:target: https://runbot.odoo-community.org/runbot/133/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
|badge1| |badge2| |badge3| |badge4| |badge5|

Make Report Actions multi-company Aware.

Expand Down Expand Up @@ -60,6 +60,10 @@ Contributors

* Jonathan Nemry <[email protected]>
* Andrea Stirpe <[email protected]>
* `XCG Consulting <https://xcg-consulting.fr/>`_:

* Étienne Ferrière
* Vincent Hatakeyama

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion ir_actions_report_multi_company/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import models
from . import models # noqa: F401
2 changes: 1 addition & 1 deletion ir_actions_report_multi_company/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": "Make Report Actions multi-company aware",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/multi-company",
"depends": ["base"],
"data": ["views/ir_actions_report_view.xml", "security/multi_company.xml"],
Expand Down
11 changes: 8 additions & 3 deletions ir_actions_report_multi_company/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-02 10:05+0000\n"
"POT-Creation-Date: 2022-06-14 08:32+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Last-Translator: Vincent Hatakeyama <[email protected]>\n"
"Language-Team: \n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 2.3\n"
"X-Generator: Poedit 2.4.2\n"

#. module: ir_actions_report_multi_company
#: model:ir.model,name:ir_actions_report_multi_company.model_ir_actions_actions
msgid "Actions"
msgstr "Actions"

#. module: ir_actions_report_multi_company
#: model:ir.model.fields,field_description:ir_actions_report_multi_company.field_ir_actions_report__company_id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ir_actions_report_multi_company
# * ir_actions_report_multi_company
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"POT-Creation-Date: 2022-06-14 08:32+0000\n"
"PO-Revision-Date: 2022-06-14 08:32+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: ir_actions_report_multi_company
#: model:ir.model.fields,field_description:ir_actions_report_multi_company.field_ir_act_report_xml_company_id
#: model:ir.model,name:ir_actions_report_multi_company.model_ir_actions_actions
msgid "Actions"
msgstr ""

#. module: ir_actions_report_multi_company
#: model:ir.model.fields,field_description:ir_actions_report_multi_company.field_ir_actions_report__company_id
msgid "Company"
msgstr ""

#. module: ir_actions_report_multi_company
#: model:ir.model,name:ir_actions_report_multi_company.model_ir_actions_report
msgid "ir.actions.report"
msgid "Report Action"
msgstr ""

3 changes: 2 additions & 1 deletion ir_actions_report_multi_company/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import ir_actions_report
from . import ir_actions_actions # noqa: F401
from . import ir_actions_report # noqa: F401
28 changes: 28 additions & 0 deletions ir_actions_report_multi_company/models/ir_actions_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2022 XCG Consulting
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, tools


class IrActions(models.Model):
_inherit = "ir.actions.actions"

# Add companies to the cache of this method that is used in
# models.BaseModels.fields_view_get to get the toolbar actions that are now
# company dependant.
@api.model
@tools.ormcache(
"frozenset(self.env.user.groups_id.ids)",
"frozenset(self.env.companies.ids)",
"model_name",
)
def get_bindings(self, model_name):
"""Retrieve the list of actions bound to the given model.
:return: a dict mapping binding types to a list of dict describing
actions, where the latter is given by calling the method
``read`` on the action record.
"""
# Using __wrapped__ is necessary to bypass the cache put by Odoo on the
# super method.
result = super().get_bindings.__wrapped__(self, model_name)
return result
4 changes: 4 additions & 0 deletions ir_actions_report_multi_company/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
* Jonathan Nemry <[email protected]>
* Andrea Stirpe <[email protected]>
* `XCG Consulting <https://xcg-consulting.fr/>`_:

* Étienne Ferrière
* Vincent Hatakeyama

0 comments on commit 461faac

Please sign in to comment.