-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1219 from OCA/14.0
Syncing from upstream OCA/web (14.0)
- Loading branch information
Showing
12 changed files
with
142 additions
and
116 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2023-11-27 11:39+0000\n" | ||
"PO-Revision-Date: 2024-02-12 10:44+0000\n" | ||
"Last-Translator: mymage <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: it\n" | ||
|
@@ -29,7 +29,7 @@ msgstr "ID" | |
#. module: web_dialog_size | ||
#: model:ir.model.fields,field_description:web_dialog_size.field_ir_config_parameter____last_update | ||
msgid "Last Modified on" | ||
msgstr "Ultima Modifica il" | ||
msgstr "Ultima modifica il" | ||
|
||
#. module: web_dialog_size | ||
#: model:ir.model,name:web_dialog_size.model_ir_config_parameter | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
from . import custom_field_restriction | ||
from . import models | ||
from . import base | ||
from . import ir_ui_view | ||
from . import ir_model |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2023 ooops404 | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) | ||
from odoo import models | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class Base(models.AbstractModel): | ||
_inherit = "base" | ||
|
||
def default_get(self, fields_list): | ||
res = super(Base, self).default_get(fields_list) | ||
if self.env.user.has_group("base.group_user"): | ||
vals = self._default_get_compute_restrictions_fields() | ||
if vals: | ||
res.update(vals) | ||
return res | ||
|
||
def _default_get_compute_restrictions_fields(self): | ||
restrictions = self.env["custom.field.restriction"].search( | ||
[("model_name", "=", self._name)] | ||
) | ||
values = {} | ||
if not restrictions: | ||
return values | ||
for r in restrictions: | ||
if r.visibility_field_id: | ||
field_name = r.visibility_field_id.name | ||
values[field_name] = False | ||
if r.required_field_id: | ||
field_name = r.required_field_id.name | ||
values[field_name] = False | ||
if r.readonly_field_id: | ||
field_name = r.readonly_field_id.name | ||
values[field_name] = False | ||
if r.group_ids: | ||
if r.group_ids & self.env.user.groups_id: | ||
values[field_name] = True | ||
return values | ||
|
||
def _compute_restrictions_fields(self): | ||
"""Common compute method for all restrictions types""" | ||
for record in self: | ||
restrictions = self.env["custom.field.restriction"].search( | ||
[("model_name", "=", self._name)] | ||
) | ||
if not restrictions: | ||
return | ||
for r in restrictions: | ||
if r.visibility_field_id: | ||
field_name = r.visibility_field_id.name | ||
record[field_name] = False | ||
if r.required_field_id: | ||
field_name = r.required_field_id.name | ||
record[field_name] = False | ||
if r.readonly_field_id: | ||
field_name = r.readonly_field_id.name | ||
record[field_name] = False | ||
if r.condition_domain: | ||
filtered_rec_id = record.filtered_domain( | ||
safe_eval(r.condition_domain) | ||
) | ||
if filtered_rec_id and r.group_ids & self.env.user.groups_id: | ||
record[field_name] = True | ||
elif r.group_ids: | ||
if r.group_ids & self.env.user.groups_id: | ||
record[field_name] = True |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2023 ooops404 | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) | ||
from odoo import fields, models | ||
|
||
|
||
class IrModel(models.Model): | ||
_inherit = "ir.model" | ||
|
||
custom_required_restriction_ids = fields.One2many( | ||
"custom.field.restriction", | ||
"required_model_id", | ||
) | ||
custom_invisible_restriction_ids = fields.One2many( | ||
"custom.field.restriction", | ||
"invisible_model_id", | ||
) | ||
custom_readonly_restriction_ids = fields.One2many( | ||
"custom.field.restriction", | ||
"readonly_model_id", | ||
) |
Oops, something went wrong.