Skip to content

Commit

Permalink
Merge pull request #1456 from OCA/12.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/server-tools (12.0)
  • Loading branch information
bt-admin authored Feb 12, 2024
2 parents 036fe09 + ef57c61 commit b426602
Show file tree
Hide file tree
Showing 37 changed files with 261 additions and 152 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ addon | version | maintainers | summary
[base_kanban_stage_state](base_kanban_stage_state/) | 12.0.1.0.0 | | Maps stages from base_kanban_stage to states
[base_locale_uom_default](base_locale_uom_default/) | 12.0.1.0.1 | | This provides settings to select default UoMs at the language level.
[base_m2m_custom_field](base_m2m_custom_field/) | 12.0.1.0.0 | | Customizations of Many2many
[base_model_restrict_update](base_model_restrict_update/) | 12.0.1.1.0 | | Update Restrict Model
[base_model_restrict_update](base_model_restrict_update/) | 12.0.1.1.1 | | Update Restrict Model
[base_multi_image](base_multi_image/) | 12.0.1.0.1 | | Allow multiple images for database objects
[base_remote](base_remote/) | 12.0.1.0.2 | | Remote Base
[base_search_fuzzy](base_search_fuzzy/) | 12.0.1.0.2 | | Fuzzy search with the PostgreSQL trigram extension
Expand All @@ -53,8 +53,8 @@ addon | version | maintainers | summary
[database_cleanup](database_cleanup/) | 12.0.1.2.1 | | Database cleanup
[datetime_formatter](datetime_formatter/) | 12.0.1.0.0 | | Helper functions to give correct format to date[time] fields
[dbfilter_from_header](dbfilter_from_header/) | 12.0.1.0.0 | | Filter databases with HTTP headers
[excel_import_export](excel_import_export/) | 12.0.1.0.7 | [![kittiu](https://github.com/kittiu.png?size=30px)](https://github.com/kittiu) | Base module for developing Excel import/export/report
[excel_import_export_demo](excel_import_export_demo/) | 12.0.1.0.2 | [![kittiu](https://github.com/kittiu.png?size=30px)](https://github.com/kittiu) | Excel Import/Export/Report Demo
[excel_import_export](excel_import_export/) | 12.0.1.0.8 | [![kittiu](https://github.com/kittiu.png?size=30px)](https://github.com/kittiu) | Base module for developing Excel import/export/report
[excel_import_export_demo](excel_import_export_demo/) | 12.0.1.0.3 | [![kittiu](https://github.com/kittiu.png?size=30px)](https://github.com/kittiu) | Excel Import/Export/Report Demo
[fetchmail_incoming_log](fetchmail_incoming_log/) | 12.0.1.0.0 | | Log all messages received, before they start to be processed.
[fetchmail_notify_error_to_sender](fetchmail_notify_error_to_sender/) | 12.0.1.0.0 | | If fetching mails gives error, send an email to sender
[html_image_url_extractor](html_image_url_extractor/) | 12.0.1.0.0 | | Extract images found in any HTML field
Expand All @@ -68,7 +68,7 @@ addon | version | maintainers | summary
[module_change_auto_install](module_change_auto_install/) | 12.0.1.0.1 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Customize auto installables modules by configuration
[onchange_helper](onchange_helper/) | 12.0.1.1.0 | | Technical module that ease execution of onchange in Python code
[scheduler_error_mailer](scheduler_error_mailer/) | 12.0.1.2.0 | | Scheduler Error Mailer
[sentry](sentry/) | 12.0.2.0.1 | [![barsi](https://github.com/barsi.png?size=30px)](https://github.com/barsi) [![naglis](https://github.com/naglis.png?size=30px)](https://github.com/naglis) [![versada](https://github.com/versada.png?size=30px)](https://github.com/versada) [![moylop260](https://github.com/moylop260.png?size=30px)](https://github.com/moylop260) [![fernandahf](https://github.com/fernandahf.png?size=30px)](https://github.com/fernandahf) | Report Odoo errors to Sentry
[sentry](sentry/) | 12.0.2.0.2 | [![barsi](https://github.com/barsi.png?size=30px)](https://github.com/barsi) [![naglis](https://github.com/naglis.png?size=30px)](https://github.com/naglis) [![versada](https://github.com/versada.png?size=30px)](https://github.com/versada) [![moylop260](https://github.com/moylop260.png?size=30px)](https://github.com/moylop260) [![fernandahf](https://github.com/fernandahf.png?size=30px)](https://github.com/fernandahf) | Report Odoo errors to Sentry
[slow_statement_logger](slow_statement_logger/) | 12.0.1.0.2 | | Log slow SQL statements
[sql_export](sql_export/) | 12.0.1.2.1 | | Export data in csv file with SQL requests
[sql_export_excel](sql_export_excel/) | 12.0.1.1.1 | | Allow to export a sql query to an excel file.
Expand Down
6 changes: 5 additions & 1 deletion base_model_restrict_update/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Update Restrict Model
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3a4496d36e2457822f0bab0c80e3b5975d90d97978ecc09b9182ecd8ebae9ebc
!! source digest: sha256:68494dd9f2cd179c4eb375459dbb6e179f9657758f0a144fe06c723173fe3c5d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -40,9 +40,13 @@ Configuration
=============

Enable the "Update Restrict Model" of specific model to restrict update from unpermitted users.

To set a user as a permitted user to update restricted model(s), click on "Grant Update Permit" in user form.

Optionally, to set a user as readonly user to all models, click on "Readonly User" in user form.

Also, you can allow readonly users to create/write/delete records of specific models by enabling "skip check for readonly users" field of specific model.

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

Expand Down
2 changes: 1 addition & 1 deletion base_model_restrict_update/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Update Restrict Model",
"version": "12.0.1.1.0",
"version": "12.0.1.1.1",
"depends": ["base"],
"website": "https://github.com/OCA/server-tools",
"author": "Odoo Community Association (OCA), Quartile Limited",
Expand Down
10 changes: 10 additions & 0 deletions base_model_restrict_update/i18n/base_model_restrict_update.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_model_restrict_update
#: model:ir.model.fields,help:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Allow readonly users to create/write/delete records of this model"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model,name:base_model_restrict_update.model_ir_model_access
msgid "Model Access"
Expand All @@ -39,6 +44,11 @@ msgstr ""
msgid "Set to true and the user can update restricted model."
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Skip Check For Readonly Users"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_res_users__unrestrict_model_update
msgid "Unrestrict Model Update"
Expand Down
10 changes: 10 additions & 0 deletions base_model_restrict_update/i18n/base_model_restrict_update.pot
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_model_restrict_update
#: model:ir.model.fields,help:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Allow readonly users to create/write/delete records of this model"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model,name:base_model_restrict_update.model_ir_model_access
msgid "Model Access"
Expand All @@ -38,6 +43,11 @@ msgstr ""
msgid "Set to true and the user can update restricted model."
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Skip Check For Readonly Users"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_res_users__unrestrict_model_update
msgid "Unrestrict Model Update"
Expand Down
19 changes: 16 additions & 3 deletions base_model_restrict_update/i18n/ja.po
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_model_restrict_update
# * base_model_restrict_update
#
msgid ""
msgstr ""
Expand All @@ -16,6 +16,11 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 4.17\n"

#. module: base_model_restrict_update
#: model:ir.model.fields,help:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Allow readonly users to create/write/delete records of this model"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model,name:base_model_restrict_update.model_ir_model_access
msgid "Model Access"
Expand All @@ -41,6 +46,11 @@ msgstr "trueに設定すると全てのモデルで読取専用ユーザにな
msgid "Set to true and the user can update restricted model."
msgstr "trueに設定するとユーザは制限付モデルを更新可能になります。"

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Skip Check For Readonly Users"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_res_users__unrestrict_model_update
msgid "Unrestrict Model Update"
Expand All @@ -58,8 +68,11 @@ msgstr "ユーザ"

#. module: base_model_restrict_update
#: model:ir.model.fields,help:base_model_restrict_update.field_ir_model__restrict_update
msgid "When selected, the model is restricted to read-only unless the user has the special permission."
msgstr "選択すると、ユーザに特別な権限がない限りモデルは読取専用に制限されます。"
msgid ""
"When selected, the model is restricted to read-only unless the user has the "
"special permission."
msgstr ""
"選択すると、ユーザに特別な権限がない限りモデルは読取専用に制限されます。"

#. module: base_model_restrict_update
#: code:addons/base_model_restrict_update/models/ir_model_access.py:27
Expand Down
10 changes: 10 additions & 0 deletions base_model_restrict_update/i18n/ja_JP.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_model_restrict_update
#: model:ir.model.fields,help:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Allow readonly users to create/write/delete records of this model"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model,name:base_model_restrict_update.model_ir_model_access
msgid "Model Access"
Expand All @@ -41,6 +46,11 @@ msgstr ""
msgid "Set to true and the user can update restricted model."
msgstr "有効化にすると制限されたモデルを更新することができます。"

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_ir_model__skip_check_for_readonly_users
msgid "Skip Check For Readonly Users"
msgstr ""

#. module: base_model_restrict_update
#: model:ir.model.fields,field_description:base_model_restrict_update.field_res_users__unrestrict_model_update
msgid "Unrestrict Model Update"
Expand Down
2 changes: 2 additions & 0 deletions base_model_restrict_update/models/ir_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ class IrModel(models.Model):
help="When selected, the model is restricted to read-only unless the "
"user has the special permission.",
)
skip_check_for_readonly_users = fields.Boolean(
help="Allow readonly users to create/write/delete records of this model")
16 changes: 10 additions & 6 deletions base_model_restrict_update/models/ir_model_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ def check(self, model, mode="read", raise_exception=True):

@api.model
def _test_readonly(self, model):
exclude_models = self._readonly_exclude_models()
if model not in exclude_models and self.env.user.is_readonly_user:
return True
return False
if not self.env.user.is_readonly_user:
return False
if model in self._readonly_exclude_models():
return False
return True

@api.model
def _test_restrict_update(self, model):
Expand All @@ -48,8 +49,11 @@ def _test_restrict_update(self, model):

@api.model
def _readonly_exclude_models(self):
""" Models updtate/create by system, and should be excluded from checking """
return self.sudo().search([
skipped_models = self.env["ir.model"].sudo().search([
"|", ("transient", "=", True), ("skip_check_for_readonly_users", "=", True)
]).mapped("model")
# Models updtate/create by system, and should be excluded from checking
return skipped_models + self.sudo().search([
("group_id", "=", False),
"|", ("perm_write", "=", True),
"|", ("perm_create", "=", True), ("perm_unlink", "=", True)
Expand Down
4 changes: 4 additions & 0 deletions base_model_restrict_update/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Enable the "Update Restrict Model" of specific model to restrict update from unpermitted users.

To set a user as a permitted user to update restricted model(s), click on "Grant Update Permit" in user form.

Optionally, to set a user as readonly user to all models, click on "Readonly User" in user form.

Also, you can allow readonly users to create/write/delete records of specific models by enabling "skip check for readonly users" field of specific model.
10 changes: 5 additions & 5 deletions base_model_restrict_update/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">Update Restrict Model</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3a4496d36e2457822f0bab0c80e3b5975d90d97978ecc09b9182ecd8ebae9ebc
!! source digest: sha256:68494dd9f2cd179c4eb375459dbb6e179f9657758f0a144fe06c723173fe3c5d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/12.0/base_model_restrict_update"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_model_restrict_update"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&amp;target_branch=12.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds a config to apply a global update restriction to specific model,
Expand All @@ -387,9 +386,10 @@ <h1 class="title">Update Restrict Model</h1>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Enable the “Update Restrict Model” of specific model to restrict update from unpermitted users.
To set a user as a permitted user to update restricted model(s), click on “Grant Update Permit” in user form.
Optionally, to set a user as readonly user to all models, click on “Readonly User” in user form.</p>
<p>Enable the “Update Restrict Model” of specific model to restrict update from unpermitted users.</p>
<p>To set a user as a permitted user to update restricted model(s), click on “Grant Update Permit” in user form.</p>
<p>Optionally, to set a user as readonly user to all models, click on “Readonly User” in user form.</p>
<p>Also, you can allow readonly users to create/write/delete records of specific models by enabling “skip check for readonly users” field of specific model.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,14 @@ def test_04_readonly_user_update_partner(self):
self.test_partner.sudo(self.permit_test_user.id).update(
{"name": "Test Partner 2"}
)

self.partner_model.restrict_update = False
with self.assertRaises(AccessError):
self.test_partner.sudo(self.permit_test_user.id).update(
{"name": "Test Partner 2"}
)

self.partner_model.skip_check_for_readonly_users = True
self.test_partner.sudo(self.permit_test_user.id).update(
{"name": "Test Partner 2"}
)
1 change: 1 addition & 0 deletions base_model_restrict_update/views/ir_model_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<field name="arch" type="xml">
<field name="transient" position="after">
<field name="restrict_update" />
<field name="skip_check_for_readonly_users" />
</field>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion excel_import_export/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Excel Import/Export/Report
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:78deb687f188890c28a7d4f4f40f0324252b02a744a44a566fa973563596f94c
!! source digest: sha256:8170ca228de882a123d060c3f434238c750a634a2f33f8fa123f6b8f158ac85b
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion excel_import_export/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
'name': 'Excel Import/Export/Report',
'summary': 'Base module for developing Excel import/export/report',
'version': '12.0.1.0.7',
'version': '12.0.1.0.8',
'author': 'Ecosoft,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/server-tools',
Expand Down
Loading

0 comments on commit b426602

Please sign in to comment.